function get_line($file,$line) {
$fp = fopen($file,'r');
$i = 0;
while(!feof($fp)) {
$i++;
$c = fgets($fp);
if($i==$line) {
echo $c;
break;
}
}
}
这个方式效率仍待考验
在一个apache的日志文件中(450M)
读取第20行非常之快 0.001039981842041
读取第200行0.0033199787139893
读取第2万行需要0.30908799171448 秒左右
读取第20万行2.5622429847717 seconds 已经到了无法忍受的地步
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn