3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $petsounds = array("cat" => "meow", "dog" => "woof", "snake" => "hiss"); $petsounds{'mouse'} = "squeak"; var_dump($petsounds); $obj = new stdClass; $obj->{'ps'} = $petsounds; $obj->ps{"fox"} = "Gding, ding, ding"; $obj->{'a123'} = "the end"; var_dump($obj); echo is_array($obj->ps)? 'true':'false',"\n"; echo is_array($obj->{'a123'})? 'true':'false',"\n";
based on cKMTJ
Output for 5.0.0 - 7.1.0
array(4) { ["cat"]=> string(4) "meow" ["dog"]=> string(4) "woof" ["snake"]=> string(4) "hiss" ["mouse"]=> string(6) "squeak" } object(stdClass)#1 (2) { ["ps"]=> array(5) { ["cat"]=> string(4) "meow" ["dog"]=> string(4) "woof" ["snake"]=> string(4) "hiss" ["mouse"]=> string(6) "squeak" ["fox"]=> string(17) "Gding, ding, ding" } ["a123"]=> string(7) "the end" } true false
Output for 4.3.0 - 4.4.9
array(4) { ["cat"]=> string(4) "meow" ["dog"]=> string(4) "woof" ["snake"]=> string(4) "hiss" ["mouse"]=> string(6) "squeak" } object(stdClass)(2) { ["ps"]=> array(5) { ["cat"]=> string(4) "meow" ["dog"]=> string(4) "woof" ["snake"]=> string(4) "hiss" ["mouse"]=> string(6) "squeak" ["fox"]=> string(17) "Gding, ding, ding" } ["a123"]=> string(7) "the end" } true false