php逐行读取txt文件写入数组的方法
来源:互联网 发布:时时彩遗漏数据软件 编辑:程序博客网 时间:2024/06/04 23:24
php逐行读取txt文件写入数组的方法
测试数据:
test01test02test03test04test05test06test07test08test09test10test11test12
$fileUrl = "E:\web\log.txt";$isss=file_exists($fileUrl) or exit("There is no file");$file = fopen($fileUrl, "r") ;$user=array();$i=0;//输出文本中所有的行,直到文件结束为止。while(! feof($file)){ $user[$i]= fgets($file);//fgets()函数从文件指针中读取一行 $i++;}fclose($file);$user=array_filter($user);print_r($user);
阅读全文