Re[2]: [PHP] foreach vs. while(list() = each())
| From: | Maxim Derkachev | Date: | Thu, 12 Apr 2001 15:23:16 +0000 |
| Subject: | Re[2]: [PHP] foreach vs. while(list() = each()) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48325@lists.php.net to get a copy of this message | ||
Hello Tim,
Thursday, April 12, 2001, 1:43:53 PM, you wrote:
TW> you can't nest foreach as you should be able to. Ecah foreach is supposed to
TW> have it's own pointer in the array, but it doesn't ... this is a known bug.
What do you mean? Foreach() can be nested, and it works perfect.
<?php
$a = array (array (1, 2, 3), array(4,5,6), array(7,8,9));
foreach ($a as $k => $first) {
print "$k:\n";
foreach ($first as $second) {
print "\t$second\n";
}
}
?>
output:
0:
1
2
3
1:
4
5
6
2:
7
8
9
--
Best regards,
Maxim Derkachev mailto:kot@books.ru
Symbol-Plus Publishing Ltd.
phone: +7 (812) 324-53-53
http://www.Books.Ru -- All Books of Russia