3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tmp_array = json_decode('{}'); $cid = "m"; $item = "Dhalia"; $cost = "10"; $tmp_array->$cid->$item = $cost; var_dump($tmp_array); $tmp_array = json_encode($tmp_array); echo $tmp_array;
based on 6Zh3J
Output for 5.4.0 - 7.3.0beta1
Warning: Creating default object from empty value in /in/fXmJk on line 7 object(stdClass)#1 (1) { ["m"]=> object(stdClass)#2 (1) { ["Dhalia"]=> string(2) "10" } } {"m":{"Dhalia":"10"}}
Output for 5.2.0 - 5.3.29
Strict Standards: Creating default object from empty value in /in/fXmJk on line 7 object(stdClass)#1 (1) { ["m"]=> object(stdClass)#2 (1) { ["Dhalia"]=> string(2) "10" } } {"m":{"Dhalia":"10"}}
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/fXmJk on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/fXmJk on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/fXmJk on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/fXmJk on line 3