3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->{'1'} = 'one'; $array = (array) $object; 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];

preferences:
42.51 ms | 402 KiB | 5 Q