3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj = (object) [1, 'bar' => 2]; foreach ($obj as $key => $val) { var_dump($key, $val); } var_dump($obj);
based on okajW
Output for 7.2.0
string(1) "0" int(1) string(3) "bar" int(2) object(stdClass)#1 (2) { ["0"]=> int(1) ["bar"]=> int(2) }
Output for 5.4.11 - 7.1.10
int(0) int(1) string(3) "bar" int(2) object(stdClass)#1 (2) { [0]=> int(1) ["bar"]=> int(2) }
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/jNgSj on line 3
Process exited with code 255.