3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $bobo = new stdclass; $bobo->{0} = 0; $bobo->{1} = 1; $bobo->{2} = 2; $bobo->{3} = 3; var_dump((array)$bobo); $sigh = (array)$bobo; $bobo['0'] = "gawd"; echo json_encode((array)$bobo);
based on NuDlt
Output for 7.2.6 - 7.3.0rc2
array(4) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) } Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/9rH0c:11 Stack trace: #0 {main} thrown in /in/9rH0c on line 11
Process exited with code 255.
Output for 7.0.0 - 7.1.20
array(4) { ["0"]=> int(0) ["1"]=> int(1) ["2"]=> int(2) ["3"]=> int(3) } Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/9rH0c:11 Stack trace: #0 {main} thrown in /in/9rH0c on line 11
Process exited with code 255.
Output for hhvm-3.11.1 - 3.17.3
array(4) { ["0"]=> int(0) ["1"]=> int(1) ["2"]=> int(2) ["3"]=> int(3) } Fatal error: Uncaught Error: Object does not implement ArrayAccess in /in/9rH0c:11 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.5.0 - 5.6.30
array(4) { ["0"]=> int(0) ["1"]=> int(1) ["2"]=> int(2) ["3"]=> int(3) } Fatal error: Cannot use object of type stdClass as array in /in/9rH0c on line 11
Process exited with code 255.