go to bug id or search bugs for
I call a function with a reference to an array and an object.
I then add the object to the end of the array.
When I then use end() and key() to get the key of the the object just added to the array key() always returns 0 rather than the actual key value.
function addToArray(&$array, $obj)
$array = $obj;
print 'last key = '.key($array).'<hr/>';
$array = array();
for ($a=0; $a<5; $a++)
I expect it to print to the screen an array dump followed by the last key value in the array 5 times (seperated by <hr>).
I add an object to the array each time, so the last key value displayed should go from 0 to 4.
the last key value is always 0 rather than the actual last key value.
Add a Patch
Add a Pull Request
I myself also noticed this bug when I installed the news 4.4.1 release this morning. 4.4.0 worked fine, but 4.4.1 is broken. This bug should be fixed ASAP as this affects (breaks) primary functions of PHP and there's no workaround for it.
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.