好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php删除txt文件指定行及按行读取txt文档数据的方法

本文实例讲述了php删除txt文件指定行及按行读取txt文档数据的方法。

向txt文件循环写入值:

$keys = range(1,999); $file = fopen('key_11010000.txt',"w"); foreach($keys as $key){   fwrite($file,"$key\r\n"); } fclose($file); $f1 = fopen('key_11010000.txt','r'); while(!feof($f1)){   $line=fgets($f1);   $line = trim($line);   $arr[] = $line; } $keys = array_filter($arr); var_dump($keys);

按行读取txt文档数据:

$f1 = fopen('key_11010000.txt','r'); while(!feof($f1)){   $line=fgets($f1);   $line = trim($line);   $arr[] = $line; } $keys = array_filter($arr); var_dump($keys); die;

查看更多关于php删除txt文件指定行及按行读取txt文档数据的方法的详细内容...

  阅读:63次