php - Is it possible to detect key type with json_encode? -
quite difficult explain, example have array:
$lol = array( 'key' => 'value', 'key_1' => 'value 1', 'simple_value', '0' => 'lol', 'key_array' => array( 'key_in_second' => 'value_with_key_in_second', 'value_in_second_array', ) );
after json_encode
{"key":"value","key_1":"value 1","0":"lol","key_array":{"key_in_second":"value_with_key_in_second","0":"value_in_second_array"}}
so possible somehow detect if in php
array had key or note? in example elements 'simple_value', '0' => 'lol'
have same key.
php doesn't care if number 0 in quotes or not. storing numeric 0, same 'value_in_second_array' 0, first element without key.
basically,
array('0'=>'lol')
same array(0=>'lol')
same array('lol')
;
you'll see simple_value dissappeared, overwritten lol.
Comments
Post a Comment