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_export($var); $var = (object) $var; var_export($var); $var = (array) $var; var_export($var); $var = json_encode($var); var_export($var); $var = json_decode($var, true); var_export($var);
based on 4vjrp
Output for 7.2.0 - 7.3.0alpha1
array ( 'a' => '1', 2 => '2', )stdClass::__set_state(array( 'a' => '1', '2' => '2', ))array ( 'a' => '1', 2 => '2', )'{"a":"1","2":"2"}'array ( 'a' => '1', 2 => '2', )
Output for 5.6.0 - 7.1.7
array ( 'a' => '1', 2 => '2', )stdClass::__set_state(array( 'a' => '1', 2 => '2', ))array ( 'a' => '1', 2 => '2', )'{"a":"1","2":"2"}'array ( 'a' => '1', 2 => '2', )