Bug #75653 [NEW]: array_values don't work on empty array
| From: | math dot piot at gmail dot com | Date: | Fri, 08 Dec 2017 13:44:54 +0000 |
| Subject: | Bug #75653 [NEW]: array_values don't work on empty array | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213012@lists.php.net to get a copy of this message | ||
From: math dot piot at gmail dot com
Operating system: Debian 9
PHP version: 7.2.0
Package: *General Issues
Bug Type: Bug
Bug description:array_values don't work on empty array
Description:
------------
If I do a array_value on an empty array, it doesn't work. It works well
if there is as least 1 value in the array.
Test script:
---------------
$array[] = 'data1'; // I want [0 => 'data1']
unset($array[0]); // I want []
$array = array_values($array); // I want [] but keys resetted
$array[] = 'data2'; // I want [0 => 'data2']
$array[] = 'data3'; // I want [0 => 'data2', 1 => 'data3']
var_dump($array);
Expected result:
----------------
array(2) {
[0]=>
string(5) "data2"
[1]=>
string(5) "data3"
}
Actual result:
--------------
array(2) {
[1]=>
string(5) "data2"
[2]=>
string(5) "data3"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=75653&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75653&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75653&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75653&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75653&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75653&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75653&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75653&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75653&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75653&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75653&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75653&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75653&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75653&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75653&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75653&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75653&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75653&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75653&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75653&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75653&r=mysqlcfg