3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->{'1'} = 'one'; echo $object->{'1'}; $array = (array) $object; $test = {'1'}; echo $array[test]; //var_dump($array); /* produces array(1) { ["1"]=> string(3) "one" } */ //none of the following will work $key = '1'; echo $array[1], $array['1'], $array["1"], $array[(string)1], $array[$key];
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
Parse error: syntax error, unexpected '{' in /in/3G5KV on line 7
Process exited with code 255.

preferences:
163.07 ms | 1395 KiB | 22 Q