note 17147 added to control-structures.foreach
| From: | dave at ovumdesign dot com | Date: | Tue, 27 Nov 2001 20:37:16 +0000 |
| Subject: | note 17147 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21349@lists.php.net to get a copy of this message | ||
foreach iterates on object attributes.
For instance, this:
class C { var $a = 1; var $b = 2; }
foreach (new C as $k => $v) echo nl2br("$k = $v\n");
outputs this:
a = 1
b = 2
This definitely works on PHP 4.0.3 and 4.0.4.
--
http://www.php.net/manual/en/control-structures.foreach.php
http://master.php.net/manage/user-notes.php?action=edit+17147
http://master.php.net/manage/user-notes.php?action=delete+17147
http://master.php.net/manage/user-notes.php?action=reject+17147