note 66833 added to control-structures.foreach
| From: | gherson at osu1 dot php dot net | Date: | Tue, 30 May 2006 19:33:14 +0000 |
| Subject: | note 66833 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112561@lists.php.net to get a copy of this message | ||
To "foreach" over the characters of a string, first "preg_split" the string into
an array:
<?php
$string="string";
$array = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
foreach($array as $char) print($char."<br/>");
?>
This outputs:
s
t
r
i
n
g
----
Server IP: 64.71.164.2
Probable Submitter: 128.122.21.82
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- http://master.php.net/note/edit/66833
Del: integrated -- http://master.php.net/note/delete/66833/integrated
Del: useless -- http://master.php.net/note/delete/66833/useless
Del: bad code -- http://master.php.net/note/delete/66833/bad+code
Del: spam -- http://master.php.net/note/delete/66833/spam
Del: non-english -- http://master.php.net/note/delete/66833/non-english
Del: in docs -- http://master.php.net/note/delete/66833/in+docs
Del: other reasons-- http://master.php.net/note/delete/66833
Reject -- http://master.php.net/note/reject/66833
Search -- http://master.php.net/manage/user-notes.php