note 66833 deleted from control-structures.foreach by googleguy
| From: | googleguy@php.net | Date: | Wed, 14 Nov 2012 22:33:21 +0000 |
| Subject: | note 66833 deleted from control-structures.foreach by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191977@lists.php.net to get a copy of this message | ||
Note Submitter: gherson
----
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