Reply to Re: Array pointer for internal(?) functions

Your name:

Reply:


Posted by Jim Michaels on 01/24/06 22:20

I thought the problem was that each() will return a fresh array each time
because of foo(). each() always adds to the array foo() returns.
I also thought a better solution would be to use a foreach lop instead of
while.
foreach (foo() as $key) {
echo "dummy";
}

"Chung Leong" <chernyshevsky@hotmail.com> wrote in message
news:1137037075.341242.66500@g43g2000cwa.googlegroups.com...
Andrι Hδnsel wrote:
> Hi!
>
> This:
>
> function foo()
> {
> $a = array('a' => 'b', 'c' => 'd');
> return array_keys($a);
> }
> while ($a = each(foo()))
> {
> echo 'dummy';
> }
>
> produces an infinite loop. Probably since the result of array_key doesn't
> support an array pointer or so, I don't know how this is internally
> implemented.
>
> Shouldn't this be considered as a bug? Shouldn't be the resulst of
> array_key
> walkable with each?

It's a bug alright--yours. foo() will return a fresh array each time,
so the condition is always true.

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация