note 18362 added to control-structures.foreach
| From: | jesse at bend dot com | Date: | Sun, 20 Jan 2002 01:14:19 +0000 |
| Subject: | note 18362 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25545@lists.php.net to get a copy of this message | ||
A couple of users have mentioned foreach() iterating over two copies of each element in an array
that you get from mysql_fetch_array(). One should note that this is not a failure of foreach(), but
instead a property of mysql_fetch_array(). If you do not want to have numerical copies of your keys
in your associative array (and you are using PHP v4.0.3 or better), it is best to use
mysql_fetch_assoc() instead.
In essense, mysql_fetch_array() is similar to array_merge(mysql_fetch_row(), mysql_fetch_assoc()),
give or take the shuffling of natural order.
I hope this helps :)
- - Jesse Thompson
--
http://www.php.net/manual/en/control-structures.foreach.php
http://master.php.net/manage/user-notes.php?action=edit+18362
http://master.php.net/manage/user-notes.php?action=delete+18362
http://master.php.net/manage/user-notes.php?action=reject+18362