在PHP中创建多数组Json文件
在我的Web应用程序中,我使用的是Json。我需要在PHP中创建以下格式的Json文件在PHP中创建多数组Json文件,php,json,Php,Json,在我的Web应用程序中,我使用的是Json。我需要在PHP中创建以下格式的Json文件 { "title": "A cool blog post", "clicks": 4000, "children": null, "published": true, "comments": [ { "author": "Mister X", "message": "A really cool postin
{
"title": "A cool blog post",
"clicks": 4000,
"children": null,
"published": true,
"comments": [
{
"author": "Mister X",
"message": "A really cool posting"
},
{
"author": "Misrer Y",
"message": "It's me again!"
}
]
}
以下是解决方案:
- 打开谷歌
- 键入PHP JSON
- 按回车键
- 单击第一个结果
- 将PHP示例中的值替换为您自己的值
- 将PHP数组编码为JSON数组
正如该链接上的exmaple所示:
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
// {"a":1,"b":2,"c":3,"d":4,"e":5}
到目前为止您尝试了什么?有代码示例吗?也许正是你想要的请记住,Stackoverflow是一个人们帮助你的网站,而不是为你做所有的工作。