php把數組寫入文件,通過序列和反序列實現。請看代碼
$file="./data/file.cache";file_put_contents($file,serialize($array));//寫入緩存
<?php
$file="./data/file.cache";
$array = array("count" => "3000", "num" =>"300");
//緩存
file_put_contents($file,serialize($array));//寫入緩存
?>
<?
$file="./data/file.cache";
$handle = fopen($file, "r");
$cacheArray = unserialize(fread($handle, filesize ($file)));
print_r($cacheArray);
?>