note 113441 added to control-structures.foreach

From: Date: Fri, 11 Oct 2013 11:11:22 +0000
Subject: note 113441 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-196523@lists.php.net to get a copy of this message
In the case the array is empty then the foreach just does not process it. <?php $a = array(); $n = 0; foreach ($a as $k) { $n += 1; } print_r($a); print "n: ".$n; ?> Output: Array ( ) n: 0 ---- Server IP: 69.147.83.199 Probable Submitter: 212.157.45.55 ---- Manual Page -- http://php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/113441 Del: integrated -- https://master.php.net/note/delete/113441/integrated Del: useless -- https://master.php.net/note/delete/113441/useless Del: bad code -- https://master.php.net/note/delete/113441/bad+code Del: spam -- https://master.php.net/note/delete/113441/spam Del: non-english -- https://master.php.net/note/delete/113441/non-english Del: in docs -- https://master.php.net/note/delete/113441/in+docs Del: other reasons-- https://master.php.net/note/delete/113441 Reject -- https://master.php.net/note/reject/113441 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196523) next »