Description
array_combine() converts a boolean false key to an empty string ("") instead of integer key 0, unlike normal PHP array-key conversion behavior.
Code to reproduce
<?php
var_dump(array_combine([true, false], ['true', 'false']));
Actual output
array(2) {
[1]=>
string(4) "true"
[""]=>
string(5) "false"
}
Expected output
array(2) {
[1]=>
string(4) "true"
[0]=>
string(5) "false"
}
Affected versions: PHP 8.4.x, PHP 8.5.x, PHP 8.6.x, and PHP 8.7.x
Additional information
Direct array construction converts boolean keys to integers:
var_dump([true => 'true', false => 'false']);
This suggests that array_combine() may be converting boolean keys to strings rather than applying the usual PHP array-key conversion rules.
PHP Version
PHP 8.4.26-dev (cli) (built: Oct 11 2026 12:44:08) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.26-dev, Copyright (c) Zend Technologies
Operating System
No response
Description
array_combine()converts a booleanfalsekey to an empty string ("") instead of integer key0, unlike normal PHP array-key conversion behavior.Code to reproduce
Actual output
Expected output
Affected versions: PHP 8.4.x, PHP 8.5.x, PHP 8.6.x, and PHP 8.7.x
Additional information
Direct array construction converts boolean keys to integers:
This suggests that
array_combine()may be converting boolean keys to strings rather than applying the usual PHP array-key conversion rules.PHP Version
Operating System
No response