note 10418 added to foreach
| From: | erik at php2 dot chek dot com | Date: | Tue, 02 Jan 2001 20:23:04 +0000 |
| Subject: | note 10418 added to foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9265@lists.php.net to get a copy of this message | ||
note that when you use a construct like this:
foreach($array as $key => $value)
to force hash-style interpretation (ala each() in perl), that hashes contain an index value as well,
so:
foreach($array as $key => $value) { echo "$key: $value\n"; };
ends up looking like this:
0: foo
mykey: foo
1: bar
myotherkey: bar
which is highly annoying but could also be useful for 'real' indexing.
http://www.php.net/manual/control-structures.foreach.php