note 77145 added to control-structures.foreach

From: Date: Thu, 16 Aug 2007 19:49:19 +0000
Subject: note 77145 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-129543@lists.php.net to get a copy of this message
In response to gherson's method of foreach'ing over a string's characters, PHP 5 now provides you with the str_split() function. So, to foreach through the characters of a string in PHP 5: <?php $string="string"; $array = str_split($string); foreach($array as $char) print($char."<br/>"); ?> This outputs: s t r i n g ---- Server IP: 64.71.164.2 Probable Submitter: 63.172.193.57 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/77145 Del: integrated -- https://master.php.net/note/delete/77145/integrated Del: useless -- https://master.php.net/note/delete/77145/useless Del: bad code -- https://master.php.net/note/delete/77145/bad+code Del: spam -- https://master.php.net/note/delete/77145/spam Del: non-english -- https://master.php.net/note/delete/77145/non-english Del: in docs -- https://master.php.net/note/delete/77145/in+docs Del: other reasons-- https://master.php.net/note/delete/77145 Reject -- https://master.php.net/note/reject/77145 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129543) next »