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]); foreach ($arr as $k => $v) { var_dump($k, $v); }
Output for 5.4.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/WWCuZ on line 9 NULL Notice: Undefined offset: 1 in /in/WWCuZ on line 10 NULL string(1) "1" string(3) "foo"
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/WWCuZ on line 9 NULL Notice: Undefined index: 1 in /in/WWCuZ on line 10 NULL string(1) "1" string(3) "foo"
Output for 5.3.0 - 5.3.29
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } bool(false) bool(false) Notice: Undefined index: 1 in /in/WWCuZ on line 9 NULL Notice: Undefined offset: 1 in /in/WWCuZ on line 10 NULL string(1) "1" string(3) "foo"
Output for 5.0.0 - 5.2.17
array(1) { ["1"]=> string(3) "foo" } array(1) { [0]=> string(1) "1" } bool(false) bool(false) Notice: Undefined index: 1 in /in/WWCuZ on line 9 NULL Notice: Undefined offset: 1 in /in/WWCuZ on line 10 NULL string(1) "1" string(3) "foo"
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" int(1) string(3) "foo"