note 18362 deleted from control-structures.foreach by sniper
| From: | sniper@php.net | Date: | Wed, 08 Oct 2003 04:10:26 +0000 |
| Subject: | note 18362 deleted from control-structures.foreach by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58013@lists.php.net to get a copy of this message | ||
Note Submitter: jesse@bend.com
----
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