3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $obj = new StdClass; $obj->{'1'} = 'foo'; $arr = (array) $obj; var_dump($arr); var_dump(array_keys($arr)); var_dump(array_key_exists('1', $arr)); var_dump(array_key_exists(1, $arr)); var_dump($arr['1']); var_dump($arr[1]);
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.1.0
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } bool(false) bool(false) Notice: Undefined offset: 1 in /in/IpCdf on line 9 NULL Notice: Undefined offset: 1 in /in/IpCdf on line 10 NULL
Output for hhvm-3.10.0 - 3.12.0
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } bool(false) bool(false) Notice: Undefined index: 1 in /in/IpCdf on line 9 NULL Notice: Undefined index: 1 in /in/IpCdf on line 10 NULL
Output for 5.0.0 - 5.4.45
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } bool(false) bool(false) NULL NULL
Output for 4.3.0 - 4.4.9
array(1) { [1]=> string(3) "foo" } array(1) { [0]=> int(1) } bool(true) bool(true) string(3) "foo" string(3) "foo"