刑美美,艾宝俊儿子,美色网
实例如下所示:
// 追加写入用户名下文件 $code="001";//动态数据 $json_string = file_get_contents("text.json");// 从文件中读取数据到php变量 $data = json_decode($json_string,true);// 把json字符串转成php数组 $data[$code]=array("a"=>"as","b"=>"bs","c"=>"cs"); $json_strings = json_encode($data); file_put_contents("text.json",$json_strings);//写入 //修改 $json_string = file_get_contents("text.json");// 从文件中读取数据到php变量 $data = json_decode($json_string,true);// 把json字符串转成php数组 $data["001"]["a"]="aas"; $json_strings = json_encode($data); file_put_contents("text.json",$json_strings);//写入
以上这篇php 读写json文件及修改json的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
php的instanceof和判断闭包Closure操作示例
php数组函数array_push()、array_pop()及array_shift()简单用法示例
yii2.0框架实现上传excel文件后导入到数据库的方法示例
php使用goto实现自动重启swoole、reactphp、workerman服务的代码
网友评论