Phpjson_encode problem rt younger brother encountered a strange problem today, just using the json encoding converted by json_encode. the circled area should be a natural sequence subscript array, but somehow it is converted into an object, however, the subscript is marked as 0. thank you for your advice. Php? Json_enco php json_encode
Rt has encountered a strange problem today
It only uses json encoding converted by json_encode. it should be a natural sequence subscript array, but it is not clear why it is converted into an object, but the subscript is marked as 0, thank you.
Php? Json_encode php json json_encode
Share:
------ Solution --------------------
When the subscript of an array does not start to increment continuously from 0, it is associated with the array.
For example
$ Ar = array (1 => 'A', 0 => 'B ');
Echo json_encode ($ ar); // {"1": "a", "0": "B "}
$ Ar = array ('A', 2 => 'B ');
Echo json_encode ($ ar); // {"0": "a", "2": "B "}