note 63805 added to function.each

From: Date: Fri, 31 Mar 2006 14:04:25 +0000
Subject: note 63805 added to function.each
Groups: php.notes 
Request: Send a blank email to php-notes+get-107072@lists.php.net to get a copy of this message
Use foreach instead of while, list and each. Foreach is: - easier to read - faster - not influenced by the array pointer, so it does not need reset(). It works like this: <?php $arr = array('foo', 'bar'); foreach ($arr as $value) { echo "The value is $value."; } $arr = array('key' => 'value', 'foo' => 'bar'); foreach ($arr as $key => $value) { echo "Key: $key, value: $value"; } ?> ---- Server IP: 194.109.193.119 Probable Submitter: 62.195.169.166 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.each.php Edit -- http://master.php.net/note/edit/63805 Del: integrated -- http://master.php.net/note/delete/63805/integrated Del: useless -- http://master.php.net/note/delete/63805/useless Del: bad code -- http://master.php.net/note/delete/63805/bad+code Del: spam -- http://master.php.net/note/delete/63805/spam Del: non-english -- http://master.php.net/note/delete/63805/non-english Del: in docs -- http://master.php.net/note/delete/63805/in+docs Del: other reasons-- http://master.php.net/note/delete/63805 Reject -- http://master.php.net/note/reject/63805 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107072) next »