Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.6.0a3

Request #9659 The userdata parameter isn't correctly send to the recursive call
Submitted: 2006-12-19 17:44 UTC
From: jean-philippe dot goydadin at rve dot ulaval dot ca Assigned: arpad
Status: Closed Package: PHP_Compat (version 1.5.0)
PHP Version: 4.4.4 OS: Windows
Roadmaps: 1.6.0a1    
Subscription  


 [2006-12-19 17:44 UTC] jean-philippe dot goydadin at rve dot ulaval dot ca (jipolin)
Description: ------------ Why the recursive call of array_walk_recursive() doesn't the exact parameter it needs ? The first and second arguments are OK ($item and $funcname) but the third give the complete array , so the function receive $item and $funcname and an array containing $item, $funcname and the $userdata variable. Then in the funcname function, if you use the $userdata parameter, you have to think that the parameters is the array and the $userdata is the third value of this array ! Test script: --------------- // Line 56 of the code in the 1.7 version // array_walk_recursive($item, $funcname, $args); // My proposition // array_walk_recursive($item, $funcname, $args[2]); // function to call function test_userdata(&$item, $key, $userdata) { $item = $userdata . ' - ' . $item; } $a = array(array('test11', 'test12', 'test13'), 'test2', array('test31', 'test32')); array_walk_recursive($a, 'test_userdata', 'print userdata'); print_r($a); Expected result: ---------------- Array ( [0] => Array ( [0] => print userdata - test11 [1] => print userdata - test12 [2] => print userdata - test13 ) [1] => print userdata - test2 [2] => Array ( [0] => print userdata - test31 [1] => print userdata - test32 ) ) Actual result: -------------- Array ( [0] => Array ( [0] => Array - test11 [1] => Array - test12 [2] => Array - test13 ) [1] => print userdata - test2 [2] => Array ( [0] => Array - test31 [1] => Array - test32 ) )

Comments

 [2007-04-06 17:00 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!