3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = new stdClass(); $a->foo = new stdClass(); $a->foo->bar = new stdClass(); $a->foo->ber = 'BEER'; $a->faa = 'AAAA'; $a->fee = 'EEEE'; var_dump($a); $toarray = (array)$a; var_dump($a);
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
object(stdClass)#1 (3) { ["foo"]=> object(stdClass)#2 (2) { ["bar"]=> object(stdClass)#3 (0) { } ["ber"]=> string(4) "BEER" } ["faa"]=> string(4) "AAAA" ["fee"]=> string(4) "EEEE" } object(stdClass)#1 (3) { ["foo"]=> object(stdClass)#2 (2) { ["bar"]=> object(stdClass)#3 (0) { } ["ber"]=> string(4) "BEER" } ["faa"]=> string(4) "AAAA" ["fee"]=> string(4) "EEEE" }
Output for 4.3.0 - 4.4.9
object(stdClass)(3) { ["foo"]=> object(stdClass)(2) { ["bar"]=> object(stdClass)(0) { } ["ber"]=> string(4) "BEER" } ["faa"]=> string(4) "AAAA" ["fee"]=> string(4) "EEEE" } object(stdClass)(3) { ["foo"]=> object(stdClass)(2) { ["bar"]=> object(stdClass)(0) { } ["ber"]=> string(4) "BEER" } ["faa"]=> string(4) "AAAA" ["fee"]=> string(4) "EEEE" }