"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));