note 104085 added to control-structures.foreach

From: Date: Sun, 22 May 2011 00:29:06 +0000
Subject: note 104085 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-179931@lists.php.net to get a copy of this message
The following code produces an unexpected result: <?php $a = array ('zero', 'one', 'two', 'three'); foreach ($a as $key => $value) echo "$key: $value\n"; var_dump(key($a)); /* Produces: 0: zero 1: one 2: two 3: three int(1) */ ?> Reset your array after using foreach on it! ---- Server IP: 69.147.83.197 Probable Submitter: 88.191.67.216 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/104085 Del: integrated -- https://master.php.net/note/delete/104085/integrated Del: useless -- https://master.php.net/note/delete/104085/useless Del: bad code -- https://master.php.net/note/delete/104085/bad+code Del: spam -- https://master.php.net/note/delete/104085/spam Del: non-english -- https://master.php.net/note/delete/104085/non-english Del: in docs -- https://master.php.net/note/delete/104085/in+docs Del: other reasons-- https://master.php.net/note/delete/104085 Reject -- https://master.php.net/note/reject/104085 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179931) next »