我想通过php显示这个json格式....
xyz({
"something": "something",
"something": "link",
"something": "",
"something": "something",
"something": "link",
"items": [
{
"something": "something",
"something": "link",
"something": { "m":"link" },
"something": "something",
"something": " <p>something<\/p> ",
"something": "something",
"something": "something",
"something": "something",
"something": "something"
},
{
"something": "something",
"something": "link",
"something": { "m":"link" },
"something": "something",
"something": " <p>something<\/p> ",
"something": "something",
"something": "something",
"something": "something",
"something": "something"
},
]
})
答案 0 :(得分:3)
也许这会对你有所帮助:
print(json_encode($yourarray));
答案 1 :(得分:3)
在这种情况下,您应该使用JSON编码:
print(json_encode($xyz));
答案 2 :(得分:3)
您可以使用以下代码:
<?php
$arr = ['1','2']; //Your array
header('Content-Type: application/json'); //See my explanation
echo json_encode($arr);
?>
虽然在其他情况下可能不需要,但如果您尝试创建类似API的格式,在我看来,您需要将Content-Type
标头设置为application/json
为以便接收方获得正确的格式。