1.将数组写入json文件
$arr=array();
$arr['username']='tongey';
$arr['age']='25';
$json_string=json_encode($arr); //将php数组转化为json字符串
file_put_contents('test.json',$json_string); //写入json文件
2.读取json文件转化为数组
$json_string=file_get_contents('test.json');
$arr=json_decode($json_string,true); //将json字符串转成php数组