Bug #75653 [Opn->Dup]: array_values don't work on empty array

From: Date: Fri, 08 Dec 2017 13:55:49 +0000
Subject: Bug #75653 [Opn->Dup]: array_values don't work on empty array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213013@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75653&edit=1 ID: 75653 Updated by: requinix@php.net Reported by: math dot piot at gmail dot com Summary: array_values don't work on empty array -Status: Open +Status: Duplicate Type: Bug -Package: *General Issues +Package: Arrays related Operating System: Debian 9 PHP Version: 7.2.0 Block user comment: N Private report: N New Comment: Basically the same as bug #75433 Previous Comments: ------------------------------------------------------------------------ [2017-12-08 13:44:53] math dot piot at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=75653&edit=1

« previous php.bugs (#213013) next »