From:
Operating system: Windows
PHP version: 5.3.2
Package: Arrays related
Bug Type: Bug
Bug description:array_walk 3rd parameter not modifying by-reference
Description:
------------
third parameters of array_walk function is not changing unless I used the
deprecated syntax of call-by-reference
Deprecated message is shown and its working properly that way.
Test script:
---------------
$cont = 0;
$sampleArray = array(0,1,1,2,3,5,8,13);
$foo = function($item,$key,$aux){
$aux++;
};
array_walk($sampleArray,$foo,$cont);
echo $cont; // it's ok. cont = 0, no call-by-reference
echo "<hr>";
$cont = 0;
$foo = function($item,$key,&$aux){
$aux++;
};
array_walk($sampleArray,$foo,$cont);
echo $cont; // it should be same as count($sampleArray) but it is 0 BUG!
echo "<hr>";
$cont = 0;
$foo = function($item,$key,&$aux){
$aux++;
};
array_walk($sampleArray,$foo,&$cont);
echo $cont; // it is 8, perfect but Deprecated: Call-time pass-by-reference
has been deprecated
Expected result:
----------------
0,8,8 should by right
but
0,0,8
--
Edit bug report at http://bugs.php.net/bug.php?id=52244&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52244&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52244&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52244&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52244&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52244&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52244&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52244&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52244&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52244&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52244&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52244&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52244&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52244&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52244&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52244&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52244&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52244&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52244&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52244&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52244&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52244&r=mysqlcfg