php逐行读取文本

2020-02-01  本文已影响0人  荒凉的岁月

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);
上一篇 下一篇

猜你喜欢

热点阅读