RE: [PHP] re: strip comma from $value

From: Date: Fri, 28 Feb 2003 17:56:12 +0000
Subject: RE: [PHP] re: strip comma from $value
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137597@lists.php.net to get a copy of this message
ereg_replace returns a string, regardless of whether or not any replacement occured. If no replacement occurs, the original string is returned. Additionally, it does not modify the original string, so you need to store the string it returns: foreach($numeric_array as $key => $value ) { if(strstr($value,",")) { $value = ereg_replace(",","",$value); echo "comma stripped"); } } Give that a shot and see if it works (I didn't test it, but it should). ---Matt -----Original Message----- From: Jim Long [mailto:jim@jimlong.net] Sent: Friday, February 28, 2003 11:42 AM To: php Subject: [PHP] re: strip comma from $value Hi, Trying this: //strip the commas from numeric array so it can sort properly------- foreach ($numeric_array as $key => $value) { if (ereg_replace ("," , "", $value)){ echo("comma striped"); } } Does the same thing as before, echo's comma stripped, but does not actually remove the commas THANKS.. any other ideas? Jim Long -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#137597) next »