3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = (array) json_decode('{"a":"1","2":"1","3":"1","4":"1","12":"1"}'); #var_dump($array); #var_dump(array_key_exists('a', $array)); #var_dump(array_key_exists(12, $array)); #var_dump($array[12]); #var_dump($array['12']); #var_dump($array[12]); #$var = (array)json_decode('{"a":"1","2":"1","3":"1","4":"1","12":"1"}'); #var_dump($var['2']); #var_export($var); $var = array('a'=>'1', '2'=>'2'); var_dump($var->{2}); $var = (object) $var; var_dump($var); $var = (array) $var; var_dump($var); $var = json_encode($var); var_dump($var); $var = json_decode($var); var_export($var);
based on 4vjrp
Output for 7.2.0 - 7.3.0alpha1
Notice: Trying to get property '2' of non-object in /in/TT9a0 on line 13 NULL object(stdClass)#1 (2) { ["a"]=> string(1) "1" ["2"]=> string(1) "2" } array(2) { ["a"]=> string(1) "1" [2]=> string(1) "2" } string(17) "{"a":"1","2":"2"}" stdClass::__set_state(array( 'a' => '1', '2' => '2', ))
Output for 5.6.0 - 7.1.7
Notice: Trying to get property of non-object in /in/TT9a0 on line 13 NULL object(stdClass)#1 (2) { ["a"]=> string(1) "1" [2]=> string(1) "2" } array(2) { ["a"]=> string(1) "1" [2]=> string(1) "2" } string(17) "{"a":"1","2":"2"}" stdClass::__set_state(array( 'a' => '1', '2' => '2', ))