Re: Removing Spaces from Array Values

From: Date: Tue, 03 Jul 2007 16:50:29 +0000
Subject: Re: Removing Spaces from Array Values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-258155@lists.php.net to get a copy of this message
foreach() is your friend for this type of operation. foreach($someArray as $value){ $new_array[]= str_replace(' ','', $value); } OR foreach($someArray as $value){ echo str_replace(' ','', $value) . "<br />\n"; } kvigor wrote:
Need to remove all spaces from Array Values... And this doesn't work. This is similar info that's within array values: $someArray[0] = "PHP is
awesome";    s/b PHPisawesome
This is similar info that's within array values: $someArray[1] = "The Toy Boat";        s/b TheToyBoat
Begin Code=================================== $num = count($someArray); for($num = 0; $cntr < $num; $cntr++) { str_replace(' ','',$someArray[$num]); echo "$someArray[$num]<br />"; } End Code===================================


« previous php.general (#258155) next »