|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-11-12 15:11 UTC] andrei at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 12:00:01 2025 UTC |
According to docs: func will be passed array value as the first parameter and array key as the second parameter. This is not happening. <? error_reporting(15); $fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple"); function test_alter( &$item1, $key, $prefix ) { $item1 = "$prefix: $item1"; } function test_print( $val, $key ) { //function test_print( $val ) { echo "$key. $val\n"; } array_walk( $fruits, 'test_print' ); array_walk( $fruits, 'test_alter', 'fruit' ); array_walk( $fruits, 'test_print' ); ?> Should get: d. lemon a. orange b. banana c. apple d. fruit: lemon a. fruit: orange b. fruit: banana c. fruit: apple I think the problem is related to this, from functions/basic_functions.c(1630?): static int _php3_array_walk(const void *a) { pval *args[1]; pval retval; args[0] = (pval *)a; call_user_function(&GLOBAL(function_table), NULL, php3_array_walk_func_name, &retval, 1, args); return 0; } The user function should expect at LEAST 2 args, but "a" contains only one argument. Sadly, I could not see my way through a patch for this (but I _REALLY_ tried! :)