[php-src] Issue #22817: The array_keys function casts the keys

From: Date: Mon, 20 Jul 2026 04:49:09 +0000
Subject: [php-src] Issue #22817: The array_keys function casts the keys
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252446@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/22817 Author: tomasnajman ### Description When using the array_keys function, a cast from string to int occurs. The function should not change the value if the text value of the key looks like a number. The following code: ```php <?php $array = ['first' => '1', '2' => '2']; $keys = \array_keys($array); echo \json_encode($keys); ``` Resulted in this output: ``` ["first",2] ``` But I expected this output instead: ``` ["first","2"] ``` ### PHP Version ```plain PHP 8.4.23 (cli) (built: Jul 1 2026 04:47:16) (NTS Visual C++ 2022 x64) Copyright (c) The PHP Group Built by The PHP Group Zend Engine v4.4.23, Copyright (c) Zend Technologies with the ionCube PHP Loader v15.5.0, Copyright (c) 2002-2026, by ionCube Ltd. ``` ### Operating System Windows 11

« previous php.bugs (#252446) next »