#31416 [Opn->Fbk]: array_walk_recursive() strange behavior
| From: | tony2001@php.net | Date: | Wed, 05 Jan 2005 15:02:08 +0000 |
| Subject: | #31416 [Opn->Fbk]: array_walk_recursive() strange behavior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-71483@lists.php.net to get a copy of this message | ||
ID: 31416
Updated by: tony2001@php.net
Reported By: sveta at microbecal dot com
-Status: Open
+Status: Feedback
Bug Type: Arrays related
Operating System: Win XP
PHP Version: 5CVS-2005-01-05 (dev)
New Comment:
Did you remove old php5ts.dll ?
How exactly did you run this code?
What php.exe -v says?
And could you plz try it under some non-MS OS ?
Previous Comments:
------------------------------------------------------------------------
[2005-01-05 14:21:46] sveta at microbecal dot com
Yes, I load sources this night and built half hour ago
May be CVS issue? Which file check?
------------------------------------------------------------------------
[2005-01-05 14:05:38] tony2001@php.net
Are your sure you tried it with the latest CVS snapshot ?
This issue was fixed about 3 weeks ago and I can't reproduce it with
CVS snapshot of any branches under Linux.
------------------------------------------------------------------------
[2005-01-05 13:51:58] sveta at microbecal dot com
Description:
------------
When I call
array_walk_recursive($array, array('Class', 'static_method1'), 'xxx');
and after it
array_walk_recursive($array, array('Class', 'static_method2'), 'xxx');
static_method2 was not called, but called static_method1
Is it right behavior?
Reproduce code:
---------------
class Test {
public static function rtrim(&$value, $key, $charlist = null) {
if (is_string($value)) {
if (null !== $charlist) {
$value = rtrim($value, $charlist);
} else {
$value = rtrim($value);
}
}
}
public static function add_suffix(&$value, $key, $suffix) {
$value = $value . $suffix;
}
}
$array = array('a' => array('b', 'c'),
'b' => array('d', 'e'),
);
array_walk_recursive($array, array('Test', 'add_suffix'), 'xxx');
var_dump($array);
array_walk_recursive($array, array('Test', 'rtrim'), 'xxx');
var_dump($array);
Expected result:
----------------
array(2) {
["a"]=>
array(2) {
[0]=>
string(4) "bxxx"
[1]=>
string(4) "cxxx"
}
["b"]=>
array(2) {
[0]=>
string(4) "dxxx"
[1]=>
string(4) "exxx"
}
}
array(2) {
["a"]=>
array(2) {
[0]=>
string(7) "b"
[1]=>
string(7) "c"
}
["b"]=>
array(2) {
[0]=>
string(7) "d"
[1]=>
string(7) "e"
}
}
Actual result:
--------------
array(2) {
["a"]=>
array(2) {
[0]=>
string(4) "bxxx"
[1]=>
string(4) "cxxx"
}
["b"]=>
array(2) {
[0]=>
string(4) "dxxx"
[1]=>
string(4) "exxx"
}
}
array(2) {
["a"]=>
array(2) {
[0]=>
string(7) "bxxxxxx"
[1]=>
string(7) "cxxxxxx"
}
["b"]=>
array(2) {
[0]=>
string(7) "dxxxxxx"
[1]=>
string(7) "exxxxxx"
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31416&edit=1