一般说来,file_put_contents只能把字符串写入文件,但是有时候需要把数组原样写入到文件,就可以用下面的方法:

<?php
$arr = [1, 234, 3454, 43653];

//将数组写入文件
file_put_contents('test.txt', print_r($arr, true));

//把数组从文件里面读出来
echo "<pre>";
print_r(file_get_contents('test.txt'));
echo "</pre>";
exit;