[php-src] Issue #23576: Next index for array returned from `array_keys()` ist wrong

From: Date: Fri, 04 Sep 2026 23:25:52 +0000
Subject: [php-src] Issue #23576: Next index for array returned from `array_keys()` ist wrong
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252704@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/23576 Author: nox-4O4 ### Description The following code: ```php <?php $a = array(123 => 123); unset($a[123]); $b = array_keys($a); $b[] = 42; var_dump($b); ``` Resulted in this output: ``` array(1) { [124]=> int(42) } ``` But I expected this output instead: ``` array(1) { [0]=> int(42) } ``` The behavior changed during a patch version update: https://3v4l.org/KR2JQ#veol This only happens when array_keys() is provided with an empty array that previously contained some elements. ### PHP Version ```plain PHP 8.4.25 (cli) (built: Aug 28 2026 07:36:03) (NTS) Copyright (c) The PHP Group Built by Debian Zend Engine v4.4.25, Copyright (c) Zend Technologies with Zend OPcache v8.4.25, Copyright (c), by Zend Technologies ``` ### Operating System _No response_

« previous php.bugs (#252704) next »