3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bobo = new stdclass; $bobo->{0} = 0; $bobo->{1} = 1; $bobo->{2} = 2; $bobo->{3} = 3; var_dump((array)$bobo); $bobo['0'] = "gawd"; echo json_encode((array)$bobo);
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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/NuDlt:10 Stack trace: #0 {main} thrown in /in/NuDlt on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.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/NuDlt:10 Stack trace: #0 {main} thrown in /in/NuDlt on line 10
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
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/NuDlt on line 10
Process exited with code 255.

preferences:
195.98 ms | 402 KiB | 223 Q