存
function set_php_file($filename, $content){
$fp = fopen($filename, "w");
fwrite($fp, $content);
fclose($fp);
}
取
function get_php_file($filename){
return trim(substr(file_get_contents($filename), 15));
}
调用
$filename = "json/navs.json";
$content = json_encode($data);
set_php_file($filename,$content);
json_decode(get_php_file($filename));
网友评论