寫入json 檔案

$fn = “/home/nanpao/www/data_text/rainfall_report/rainfall.json”;

if(file_exists($fn)){
unlink($fn);
$fp = fopen($fn , ‘w’);
fwrite($fp, json_encode($cwbdat));
fclose($fp);
} else {
$fp = fopen($fn , ‘w’);
fwrite($fp, json_encode($cwbdat));
fclose($fp);
}