i need to store php variables into files so i decide to serialize or jsonize (maybe jsonify XD) them.
For portability purpose i prefer json solution...
During test i notice associative array are json-decoded as object and i cant use it as associative array but i have to use as object.
Non-associative array are json-decoded correctly as non-associative array..
am i doing something wrong?
or just this is a normal behavior of php json functions
here the example code
$test = array("test1" => 1, "test2" => 2);
$json = json_decode(json_encode($test));
$serialize = unserialize(serialize($test));
//output -> stdClass::__set_state(array( 'test1' => 1, 'test2' => 2, ))
// cant access to $json["test1"] as in $test but $json->test why?????
var_export($json);
//ouptut -> array ( 'test1' => 1, 'test2' => 2, )
//here i can $serialize["test1"]
var_export($serialize);
json_decode(json_encode($test), true);, you'll get an array instead of an object.