{键值对}
: json对象[{},{},{}]
:json数组
标准json格式
[
{
"id":"001",
"title":"百度",
"url":"http://www.baidu.com"
},
{
"id":"002",
"title":"阿里",
"url":"www.alibaba.com"
},
{
"id":"003",
"title":"腾讯",
"url":"www.qq.com"
}
]
php的json_encode()和fopen()函数生成添加
{"username":"qwe","password":"0001"}{"username":"zxc","password":"589"}{"username":"uyut","password":"369"}
php文件
$userInfo = $_POST;
//把获取的用户信息数组编码成json字符串
$json = json_encode($userInfo);
//打开json文件,如果没有json文件则自动创建json文件
$file = fopen('789.json','rb+');
fread($file, 1);//移动文件指针位置
//把json字符串$json写入json文件form.json
fwrite($file,$json);
//关闭文件
fclose($file);
暂无评论