From: [EMAIL PROTECTED]
Operating system: *
PHP version: 5CVS-2005-10-25 (CVS)
PHP Bug Type: Arrays related
Bug description: array_walk_recursive() modifies elements outside function
scope
Description:
------------
array_walk_recursive() modifies element values deeper than the first level
on vars outside the scope of the function call.
Reproduce code:
---------------
<?php
$ar = array(
'element 1',
array('element2 => subelement1')
);
func($ar);
var_dump($ar);
function func($a) {
array_walk_recursive($a, 'apply');
}
function apply(&$input, $key) {
$input = 'changed';
}
Expected result:
----------------
array(2) {
[0]=>
string(9) "element 1"
[1]=>
array(1) {
[0]=>
string(23) "element2 => subelement1"
}
}
Actual result:
--------------
array(2) {
[0]=>
string(9) "element 1"
[1]=>
array(1) {
[0]=>
string(7) "changed"
}
}
--
Edit bug report at http://bugs.php.net/?id=34982&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34982&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34982&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34982&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34982&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34982&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34982&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34982&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34982&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34982&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34982&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34982&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34982&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34982&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34982&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34982&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34982&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34982&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34982&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34982&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34982&r=mysqlcfg