note 105765 added to control-structures.foreach

From: Date: Tue, 13 Sep 2011 13:16:26 +0000
Subject: note 105765 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-183133@lists.php.net to get a copy of this message
<?php foreach (array() as $value){ echo $value; // Prints nothing here } ?> The code above always prints nothing, because array() returns empty array. So $value always be empty and echo has nothing to print - you never know if foreach is in loop. If you would like to test how foreach works with empty array() try this code: <?php foreach (array() as $value) { echo 'I wont read this'; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 89.78.81.151 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/105765 Del: integrated -- https://master.php.net/note/delete/105765/integrated Del: useless -- https://master.php.net/note/delete/105765/useless Del: bad code -- https://master.php.net/note/delete/105765/bad+code Del: spam -- https://master.php.net/note/delete/105765/spam Del: non-english -- https://master.php.net/note/delete/105765/non-english Del: in docs -- https://master.php.net/note/delete/105765/in+docs Del: other reasons-- https://master.php.net/note/delete/105765 Reject -- https://master.php.net/note/reject/105765 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183133) next »