"APPLE",1=>"BABABA")),JSON_FORCE_OBJECT);//string(18) "["APPLE","BABABA"]"
Last two lines:
var_dump(json_encode((object)array(0=>"APPLE",1=>"BABABA",2=>'PEAR')));// string(37) "{"0":"APPLE","1":"BABABA","2":"PEAR"}"var_dump(json_encode(array(0=>"APPLE",1=>"BABABA",2=>'PEAR')),JSON_FORCE_OBJECT);string(25) "["APPLE","BABABA","PEAR"]"int(16)
What is an int (16)? Add Json_force_object is not good, if the subscript does not start with 0, or key is not continuous, is an object, otherwise is an array, which predecessors to explain why, why.
Reply content:
"APPLE",1=>"BABABA")),JSON_FORCE_OBJECT);//string(18) "["APPLE","BABABA"]"
Last two lines:
var_dump(json_encode((object)array(0=>"APPLE",1=>"BABABA",2=>'PEAR')));// string(37) "{"0":"APPLE","1":"BABABA","2":"PEAR"}"var_dump(json_encode(array(0=>"APPLE",1=>"BABABA",2=>'PEAR')),JSON_FORCE_OBJECT);string(25) "["APPLE","BABABA","PEAR"]"int(16)
What is an int (16)? Add Json_force_object is not good, if the subscript does not start with 0, or key is not continuous, is an object, otherwise is an array, which predecessors to explain why, why.
Please carefully compare the following two lines
var_dump(json_encode(array(0=>"APPLE",1=>"BABABA",2=>'PEAR')),JSON_FORCE_OBJECT);var_dump(json_encode(array(0=>"APPLE",1=>"BABABA",2=>'PEAR'),JSON_FORCE_OBJECT));