Bug #69166 [Opn]: Assigning array_values() to array does not reset key counter
Edit report at https://bugs.php.net/bug.php?id=69166&edit=1
ID: 69166
Updated by: cweiske@php.net
Reported by: cweiske@php.net
Summary: Assigning array_values() to array does not reset key
counter
Status: Open
Type: Bug
Package: Arrays related
PHP Version: master-Git-2015-03-03 (Git)
Block user comment: N
Private report: N
New Comment:
Also see http://3v4l.org/s5fJX
Previous Comments:
------------------------------------------------------------------------
[2015-03-03 07:52:19] cweiske@php.net
Description:
------------
When assigning the result of array_values() to an array variable, its internal key counter does not
get reset anymore as it did on PHP 4 and PHP 5.
Test script:
---------------
<?php
$ar = array('foo');
unset($ar[0]);
$ar = array_values($ar);
$ar[] = 'bar';
var_dump($ar);
?>
Expected result:
----------------
array(1) {
[0] =>
string(3) "bar"
}
Actual result:
--------------
array(1) {
[1]=>
string(3) "bar"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69166&edit=1
Thread (4 messages)