3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $x = array('12' => 34); var_dump($x); var_dump(gettype(key($x))); var_dump(array_key_exists(true, $x)); var_dump(array_key_exists(12, $x)); var_dump(array_key_exists('12', $x)); var_dump(array_key_exists(12.0, $x));
Output for 4.3.2 - 5.6.28, 7.0.0 - 7.1.0
array(1) { [12]=> int(34) } string(7) "integer" Warning: array_key_exists(): The first argument should be either a string or an integer in /in/SHI79 on line 7 bool(false) bool(true) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/SHI79 on line 10 bool(false)
Output for hhvm-3.10.0 - 3.12.0
array(1) { [12]=> int(34) } string(7) "integer" Warning: Array key should be either a string or an integer in /in/SHI79 on line 7 bool(false) bool(true) bool(true) Warning: Array key should be either a string or an integer in /in/SHI79 on line 10 bool(false)
Output for 4.3.0 - 4.3.1
array(1) { [12]=> int(34) } string(7) "integer" Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The first argument should be either a string or an integer in /in/SHI79 on line 7 bool(false) bool(true) bool(true) Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The first argument should be either a string or an integer in /in/SHI79 on line 10 bool(false)