kvigor wrote:
Need to remove all spaces from Array Values... And this doesn't work.
Are we talking spaces ' ' or all white space? This may include a tab, space, new line, etc...
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===================================
This should do for you
<plaintext><?php
$someArray = array();
$someArray[] = "somethig specia to take apart";
$someArray[] = "somethig
specia to take apart";
$someArray[] = "somethig specia to
take apart
";
print_r($someArray);
foreach ( $someArray AS $k => $v ) {
$someArray[$k] = preg_replace('!\s!', '', $v); // Removes white space ' ', \n, \r\n, etc...
$someArray[$k] = str_replace(' ', '', $v); // Removes only spaces
}
print_r($someArray);
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php