Re: [PHP-DEV] PHP 4.0 Bug #2956: array_walk not working as it did in php 3.0? From: Andrei Zmievski (andrei <email protected>)
Date: 12/10/99

At 01:54 AM 12/11/99 +0000, fvkuipers <email protected> 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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>