|
Posted by Peter van Schie on 10/10/07 11:24
Erwin Moller wrote:
> Hi,
>
> Look at the function name file() at www.php.net.
> It reads lines into an array.
> Take the first 10...
If the file is big, it's not very efficient to read the whole file into
an array, using file().
I'd suggest using something like:
<?php
if (($hFile = fopen("file.txt", "r")))
{
for ($iLine = 0; $iLine < 10; $iLine++)
{
$strLine = fgets($hFile);
// do something with $strLine
//
}
}
else
{
// error handling
//
}
?>
Peter.
--
http://www.phpforums.nl
Navigation:
[Reply to this message]
|