php逐行读取文本内容
$filepath = "example.txt";
$file = fopen($filepath, "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
//feof() check if file read end EOF
while(!feof($file))
{
//fgets() Read row by row
$line = fgets($file);
if(!empty(trim($line)))echo $line;
}
fclose($file);
网友评论