0perator Posted June 19, 2008 Share Posted June 19, 2008 i have some whitespace it REFUSES to go, even when i use chop and trim, and str_replace and explode() please help Link to comment https://forums.phpfreaks.com/topic/110911-whitespace/ Share on other sites More sharing options...
rarebit Posted June 19, 2008 Share Posted June 19, 2008 show example code... Link to comment https://forums.phpfreaks.com/topic/110911-whitespace/#findComment-568992 Share on other sites More sharing options...
0perator Posted June 19, 2008 Author Share Posted June 19, 2008 <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIE, "PHPSESSID=pmo5ssg2ffbf4r5fk7o698emi4; PHPSESSID=kk9q6o9v1momaruilfteu9usv7; enigmafiedV4=a%3A4%3A%7Bi%3A0%3Bs%3A4%3A%221813%22%3Bi%3A1%3Bs%3A40%3A%22e67ebe875f7160d8a4680aab6f0038ca824396b1%22%3Bi%3A2%3Bi%3A1401991156%3Bi%3A3%3Bi%3A2%3B%7D"); curl_setopt($ch, CURLOPT_URL, "http://www.enigmagroup.org/missions/programming/7/index.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); $da = explode(".", $result); $be = explode(": ", $da[17]); $one = $be[2]; $two = $da[18]; $three = $da[19]; $four = $da[20]; $five = $da[21]; $string = "".$one.".".$two.".".$three.".".$four.".".$five[0].""; $space = explode(" ", $result); $dept = $space[37]; $reet = explode(" ", $result); $num = substr_count($result, $dept); $val = 100; $i = 0; $reetval = 103; while($val <= 300){ $check = $reet[$val]; if($check == $dept){ $cost[$i] = str_replace("$", "", $reet[$reetval]); $val = $val +5; $reetval = $reetval + 5; $i = $i + 1; //echo $check; } else{ $val = $val +5; $reetval = $reetval + 5; } } $sumt = array_sum($cost); $sum=preg_replace('/\s+/','',$sumt); $comp = substr($string, 0, ($output-1)); echo "company=".$comp."&department=".$dept."&total=".$sum; //$sum = substr_replace($sumt,"",-1); $new = curl_init(); curl_setopt($new, CURLOPT_RETURNTRANSFER, 1); curl_setopt($new, CURLOPT_COOKIE, "PHPSESSID=pmo5ssg2ffbf4r5fk7o698emi4; PHPSESSID=kk9q6o9v1momaruilfteu9usv7; enigmafiedV4=a%3A4%3A%7Bi%3A0%3Bs%3A4%3A%221813%22%3Bi%3A1%3Bs%3A40%3A%22e67ebe875f7160d8a4680aab6f0038ca824396b1%22%3Bi%3A2%3Bi%3A1401991156%3Bi%3A3%3Bi%3A2%3B%7D"); curl_setopt($new, CURLOPT_URL, "http://www.enigmagroup.org/missions/programming/7/submit.php"); curl_setopt($new, CURLOPT_POST, 1); curl_setopt($new, CURLOPT_POSTFIELDS, "company=".$comp."&department=".$dept."&total=".$sum); $points = curl_exec($new); echo $points; ?> i get whitespace on $comp and $sum Link to comment https://forums.phpfreaks.com/topic/110911-whitespace/#findComment-568995 Share on other sites More sharing options...
rarebit Posted June 19, 2008 Share Posted June 19, 2008 this works for me: $s = "a b c d e f g h i"; $sum=preg_replace('/\s+/','',$s); print $sum."<br>"; Link to comment https://forums.phpfreaks.com/topic/110911-whitespace/#findComment-569036 Share on other sites More sharing options...
0perator Posted June 19, 2008 Author Share Posted June 19, 2008 ah got it to work now, thanks Link to comment https://forums.phpfreaks.com/topic/110911-whitespace/#findComment-569040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.