PHP从文件中逐字逐句阅读

时间:2017-05-01 15:10:35

标签: php file loops

如果我注释掉它打印文件的if语句,为什么这段代码不起作用。

<?php

$f = fopen("test.txt", "r");

// Read line by line until end of file
while(!feof($f)) { 
    $arrays = explode("\n",fgets($f));
    foreach($arrays as $words){
        if($words == "andersmarkc"){
            echo $words;
        }
    }
}

fclose($f);

?>

0 个答案:

没有答案