My user contributed error :(
| From: | timgolding | Date: | Tue, 28 Apr 2009 10:14:17 +0000 |
| Subject: | My user contributed error :( | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-4552@lists.php.net to get a copy of this message | ||
Hi I just submitted a user contributed note to foreach and it is wrong. It is timgolding_10@hotmail.com and talks about looping through a string.
$string='hello';
foreach((array)$string as $char)
echo $char;
//hello
This is wrong as then the value 'hello' is passed to $char with one iteration.
It should read:
$string='hello';
foreach(str_split($string) as $char)
echo $char;
//hello
I did test it but not very well. could you either delete it. Or replace the code as above?