Bug #52244 [NEW]: array_walk 3rd parameter not modifying by-reference
| From: | davidcanos at gmail dot com | Date: | Sun, 04 Jul 2010 11:11:39 +0000 |
| Subject: | Bug #52244 [NEW]: array_walk 3rd parameter not modifying by-reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-152068@lists.php.net to get a copy of this message | ||
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