PHP 4.0 Bug #2980: array_walk behaves different than in php3

From: Date: Wed, 15 Dec 1999 18:41:15 +0000
Subject: PHP 4.0 Bug #2980: array_walk behaves different than in php3
Groups: php.dev 
Request: Send a blank email to php-dev+get-13721@lists.php.net to get a copy of this message
From: hholzgra@media-engineering.de Operating system: PHP version: 4.0 Latest CVS (15/12/1999) PHP Bug Type: Misbehaving function Bug description: array_walk behaves different than in php3 array_walk() PHP4 won't reset() the array before walking, it will start at the current position instead of the first element as php3 does ? is this a bug or a feature ? if it is a feature, than the example in the documentation has to be changed ... <pre> $fruits=array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple"); function test_alter( &$item1, $key, $prefix ) { $item1 = "$prefix: $item1"; } function test_print( $item2, $key ) { echo "$key. $item2<br>\n"; } array_walk( $fruits, 'test_print' ); array_walk( $fruits, 'test_alter', 'fruit' ); array_walk( $fruits, 'test_print' ); </pre> will need a 'reset($fruits);' before call #2 and #3 of array_walk to work

« previous php.dev (#13721) next »