php逐行读取文本文件的内容。
php文件
$handler = fopen(‘test6.txt‘,‘r‘); //打开文件 while(!feof($handler)){ $m[] = fgets($handler,4096); //fgets逐行读取,4096最大长度,默认为1024 } fclose($handler); //关闭文件 //输出文件 echo ‘<pre>‘; print_r($m); echo ‘</pre>‘;
Text文本
ddddds sdfasdfa dfasdfa lk;k;kh;k dddfsfas sdfasdfa dddd dsflka;lsdk
结果
Array ( [0] => ddddds [1] => sdfasdfa [2] => dfasdfa [3] => lk;k;kh;k [4] => dddfsfas [5] => sdfasdfa [6] => dddd [7] => dsflka;lsdk )
PHP逐行读取Text文本文件
时间: 2024-10-06 06:53:25