3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"key1":"value1","key2":"value2"}'; $asObject = json_decode($json); var_dump($asObject); $asArray = json_decode($json, true); var_dump($asArray); foreach($asArray as $v){ echo $v; } // no problem; $asArray['anotherKey'] = 'anotherValue'; // no problem foreach($asObject as $v){ echo $v; } $asObject['anotherKey'] = 'anotherValue'; // E_ERROR : type 1 -- Cannot use object of type stdClass as array
Output for git.master, git.master_jit, rfc.property-hooks
object(stdClass)#1 (2) { ["key1"]=> string(6) "value1" ["key2"]=> string(6) "value2" } array(2) { ["key1"]=> string(6) "value1" ["key2"]=> string(6) "value2" } value1value2value1value2 Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /in/1dZLv:18 Stack trace: #0 {main} thrown in /in/1dZLv on line 18
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.93 ms | 2062 KiB | 4 Q