TheSqrtMinus1 TheSqrtMinus1 - 7 months ago 11
PHP Question

How do I echo the first 500 lines of a file with php?

It's a pretty big file, it'll end up being around a gigabyte.

I just want to show the first 500 lines. The file is preformatted, as it is a log.

Answer

You can do like;

<?php
$data = file('data.txt');
for($i=0;$i<500;$i++){
    echo $data[$i];
}
?>