Re: PHP 4.0 Bug #2956: array_walk not working as it did in php 3.0?

From: Date: Sat, 11 Dec 1999 04:10:21 +0000
Subject: Re: PHP 4.0 Bug #2956: array_walk not working as it did in php 3.0?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-13576@lists.php.net to get a copy of this message
At 01:54 AM 12/11/99 +0000, fvkuipers@home.com wrote: >This example is taken from the php3 documentation, and works in php3: > >$fruits = >array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple"); > >function test_alter( &$item1 ) { > $item1 = 'bogus'; >} > >function test_print( $item2 ) { > echo "$item2<br>\n"; >} > >array_walk( $fruits, 'test_print' ); >array_walk( $fruits, 'test_alter' ); >array_walk( $fruits, 'test_print' ); > >When I run this, I get the following and NOTHING else: > >lemon<br> >orange<br> >banana<br> >apple<br> > >It seems that the array is traversed the first time, but not the next two >times... perhaps it needs to restore the array pointer?? See the >modification to this code: Yes, you need to reset the array between array_walk() calls. -Andrei

« previous php.dev (#13576) next »