Bug #69166 [Opn]: Assigning array_values() to array does not reset key counter

From: Date: Tue, 03 Mar 2015 07:56:58 +0000
Subject: Bug #69166 [Opn]: Assigning array_values() to array does not reset key counter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191072@lists.php.net to get a copy of this message
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)

« previous php.bugs (#191072) next »