3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // *convert array to object* $array_name = ["id" => 321313,"username" => "shahbaz"]; $object = (object) $array_name; //now it is converted to object and you can access it. echo $object->username; echo $object["username"]; $o = new ArrayObject($array_name); echo "\n",($o == $object)? 'true': 'false',"\n"; echo $o["username"];
Output for 7.0.0 - 7.2.6
shahbaz Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/ngXm4:9 Stack trace: #0 {main} thrown in /in/ngXm4 on line 9
Process exited with code 255.
Output for hhvm-3.15.4
shahbaz Fatal error: Uncaught Error: Object does not implement ArrayAccess in /in/ngXm4:9 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
shahbaz Fatal error: Cannot use object of type stdClass as array in /in/ngXm4 on line 9
Process exited with code 255.