我正在尝试将 json_encode 输出为:{"match_all":{}}。 我写的示例程序是:
<?php
$qarray=Array("match_all"=>Array());
print_r(json_encode($qarray));
?>
但上面是给我下面的 o/p: {“匹配所有”:[]}
最佳答案
您想要的是对象
,而不是数组
。这将生成您想要的输出。
$qarray = array("match_all" => new stdClass());
print_r(json_encode($qarray));
关于php - 如何使用 json_encode 更正 php 中的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47815944/