【发布时间】:2017-03-17 13:47:38
【问题描述】:
我有这个数组:
$array = [
"stored_fields" => ["id"],
"match_all" => []
];
我想要:
{"stored_fields":["id"],"match_all":{}}
但是,当我打电话时:
echo json_encode($array);
我明白了:
{"stored_fields":["id"],"match_all":[]}
如果我使用:
echo json_encode($array, JSON_FORCE_OBJECT);
我明白了:
{"stored_fields":{"0":"id"},"match_all":{}}
我能做什么?
【问题讨论】: