1、代码如下
<?php $file = "demo.txt"; $array=array('color'=> array('blue','red','green'),'size'=> array('small','medium','large')); //缓存 if(false!==fopen($file,'w+')){ file_put_contents($file,serialize($array));//写入缓存 } //读出缓存 $handle=fopen($file,'r'); $cacheArray=unserialize(fread($handle,filesize($file))); echo "<pre>"; print_r($array); echo "<pre>"; ?>
标签:缓存,fopen,写入,file,array,txt,php From: https://www.cnblogs.com/wlei5206/p/16822669.html