note 66721 added to control-structures.foreach
| From: | bdnt at gmx dot net | Date: | Sat, 27 May 2006 05:55:56 +0000 |
| Subject: | note 66721 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112351@lists.php.net to get a copy of this message | ||
i suggest, DO NOT USE the second syntax
<?php
foreach ($arr $key=>$val)
{
}
?>
if in the future you use mmcache (for encoded or optimization) you'll come in serious error.
mmcache seems always look the array as numerical's index not as associative array. Better use
this syntax
<?php
foreach (array_keys($arr) as $key)
{
$val = $arry[$key];
}
?>
This script will be executed much faster (please do the benchmark yourself) and mmcache will be
correctly interpret by mmcache.
----
Server IP: 202.67.10.139
Probable Submitter: 202.153.247.75
----
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/control-structures.foreach.php
Edit -- http://master.php.net/note/edit/66721
Del: integrated -- http://master.php.net/note/delete/66721/integrated
Del: useless -- http://master.php.net/note/delete/66721/useless
Del: bad code -- http://master.php.net/note/delete/66721/bad+code
Del: spam -- http://master.php.net/note/delete/66721/spam
Del: non-english -- http://master.php.net/note/delete/66721/non-english
Del: in docs -- http://master.php.net/note/delete/66721/in+docs
Del: other reasons-- http://master.php.net/note/delete/66721
Reject -- http://master.php.net/note/reject/66721
Search -- http://master.php.net/manage/user-notes.php