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($arr['1']); var_dump($arr[1]);
Output for 5.4.0 - 7.1.0
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } Notice: Undefined offset: 1 in /in/87211 on line 7 NULL Notice: Undefined offset: 1 in /in/87211 on line 8 NULL
Output for 5.3.0 - 5.3.29
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } Notice: Undefined index: 1 in /in/87211 on line 7 NULL Notice: Undefined offset: 1 in /in/87211 on line 8 NULL
Output for 5.0.0 - 5.2.17
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } Notice: Undefined index: 1 in /in/87211 on line 7 NULL Notice: Undefined offset: 1 in /in/87211 on line 8 NULL
Output for 4.3.0 - 4.4.9
array(1) { [1]=> string(3) "foo" } array(1) { [0]=> int(1) } string(3) "foo" string(3) "foo"