php把数组写入文件
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);
?>