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.p
hp.net/note/edit/63805
Del: integrated -- ht
tp://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://m
aster.php.net/note/delete/63805/spam
Del: non-english -- h
ttp://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://ma
ster.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|