Bug #69166 [NEW]: Assigning array_values() to array does not reset key counter
From: cweiske
Operating system:
PHP version: master-Git-2015-03-03 (Git)
Package: Arrays related
Bug Type: Bug
Bug description:Assigning array_values() to array does not reset key counter
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 bug report at https://bugs.php.net/bug.php?id=69166&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69166&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69166&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69166&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69166&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69166&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69166&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69166&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69166&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69166&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69166&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69166&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69166&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69166&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69166&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69166&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69166&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69166&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69166&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69166&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69166&r=mysqlcfg
Thread (4 messages)
- cweiske@php.net