php 代码:
[code lang=”php”]
function getLines($path)
{
$f = fopen($path,’r’);
while(!feof($f))
{
$data = fgets($f);
yield $data;
}
fclose($f);
}
foreach(getLines($path) as $line=>$val)
{
if($line>100000) break;
echo $val."<br />";
}
[/code]