"BABABA")),JSON_FORCE_OBJECT);//string(18) "["APPLE","BABABA"]"最后两行:var_dump(json_encode((object)array(0=>"AP">
时间:2021-07-01 10:21:17 帮助过:24人阅读
"APPLE",1=>"BABABA")),JSON_FORCE_OBJECT);
//string(18) "["APPLE","BABABA"]"
最后两行:
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)
int (16) 是个啥??加了json_force_object也不好使呢,如果下标不以0开头,或者key不连续,就是object,否则就是数组,哪位前辈给大概解释下为啥,为啥。
"APPLE",1=>"BABABA")),JSON_FORCE_OBJECT);
//string(18) "["APPLE","BABABA"]"
最后两行:
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)
int (16) 是个啥??加了json_force_object也不好使呢,如果下标不以0开头,或者key不连续,就是object,否则就是数组,哪位前辈给大概解释下为啥,为啥。
请仔细对比以下两行
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));