note 16969 added to control-structures.foreach
| From: | basil dot hussain at kodakweddings dot com | Date: | Tue, 20 Nov 2001 18:17:28 +0000 |
| Subject: | note 16969 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21069@lists.php.net to get a copy of this message | ||
There is some undocumented behaviour with foreach() to do with objects. If you use the following
code:
foreach($myarray as $x->y) {
...
}
On each iteration, $x will be created as an object (of class 'stdClass') with the property
y containing the value of the current array element.
This could catch you out if you type "->" instead of "=>", so beware!
--
http://www.php.net/manual/en/control-structures.foreach.php
http://master.php.net/manage/user-notes.php?action=edit+16969
http://master.php.net/manage/user-notes.php?action=delete+16969
http://master.php.net/manage/user-notes.php?action=reject+16969