|
Posted by Mladen Gogala on 01/12/06 05:48
On Thu, 12 Jan 2006 03:45:30 +0100, André Hänsel wrote:
> function foo()
> {
> $a = array('a' => 'b', 'c' => 'd');
> return array_keys($a);
> }
> while ($a = each(foo()))
> {
> echo 'dummy';
> }
Andre, the problem is not in the pointer, the problem is in the
loop. The function foo() will be called each time the loop condition
is checked, producing always a new array and a new set of keys.
Here is a code that does work:
$ cat /tmp/ttt;
<?
function foo() {
$a = array('a' => 'b', 'c' => 'd');
return array_keys($a);
}
$b=foo();
while ($a = each($b))
{
echo "dummy\n";
}
?>
$ php /tmp/ttt
dummy
dummy
--
http://www.mgogala.com
Navigation:
[Reply to this message]
|