4
json_encode将PHP数组稀疏为JSON数组,而不是JSON对象
我在PHP中有以下数组: Array ( [0] => Array ( [id] => 0 [name] => name1 [short_name] => n1 ) [2] => Array ( [id] => 2 [name] => name2 [short_name] => n2 ) ) 我想将其JSON编码为JSON数组,产生类似以下内容的字符串: [ { "id":0, "name":"name1", "short_name":"n1" }, { "id":2, "name":"name2", "short_name":"n2" } ] 但是当我调用json_encode此数组时,得到以下信息: { "0":{ "id":0, "name":"name1", …