// 追加寫入用戶名下文件
$code="001";//動態(tài)數(shù)據(jù)
$json_string = file_get_contents("text.json");// 從文件中讀取數(shù)據(jù)到PHP變量
$data = json_decode($json_string,true);// 把JSON字符串轉(zhuǎn)成PHP數(shù)組
$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");// 從文件中讀取數(shù)據(jù)到PHP變量
$data = json_decode($json_string,true);// 把JSON字符串轉(zhuǎn)成PHP數(shù)組
$data["001"]["a"]="aas";
$json_strings = json_encode($data);
file_put_contents("text.json",$json_strings);//寫入