日期:2014-05-17 浏览次数:20499 次
$arr_old = array(1,55,2,36,77); print_r($arr_old); /* Array ( [0] => 1 [1] => 55 [2] => 2 [3] => 36 [4] => 77 ) */ $file_name_old="test.php"; $file_old=fopen($file_name_old,"w"); fwrite($file_old,serialize($arr_old)); fclose($file_old); $file_name_new="test.php"; $file_new=fopen($file_name_new,"r"); $file_read = fread($file_new, filesize($file_name_new)); fclose($file_new); $arr_new = unserialize($file_read); print_r($arr_new); /* Array ( [0] => 1 [1] => 55 [2] => 2 [3] => 36 [4] => 77 ) */
------解决方案--------------------
3楼说的方法
<?php $yourArray = array('aqw568', 'sdtrnz2006', 'gggudf');// 原来的数组 file_put_contents('aa.txt', serialize($yourArray));// 序列化并写入文件 $readArray = unserialize(file_get_contents('aa.txt'));// 读取并反序列化 print_r($readArray); ?>