您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/9/28 5:43:25发布25次查看
本文实例讲述了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程序设计有所帮助。
更多php删除txt文件指定行及按行读取txt文档数据的方法。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product