我似乎不能让我的json_encode包括括号。有什么帮助吗?
我的代码是:
$th = json_encode(array("4" => "four", "8" => "eight"));
echo $th;,输出为:
{"4":"four","8":"eight","9":"\n"}我需要发送到api的输出是:
[{"4":"four","8":"eight","9":"\n"}]如何获得JSON数组中的括号?谢谢!
发布于 2012-11-06 03:13:16
使用这个
$th = json_encode(array(array("4" => "four", "8" => "eight", "9" => "\n")));发布于 2012-11-05 23:10:50
你应该这样做:
$th = json_encode(array(array("4" => "four", "8" => "eight")));https://stackoverflow.com/questions/13241851
复制相似问题