|
Posted by Pedro Graca on 10/13/06 18:17
[ Please don't top-post. Read http://www.caliburn.nl/topposting.html ]
ZabMilenko top-posted (corrected):
> howa wrote:
>> hi,
>>
>> how to read a large php file line by line?
>>
>> fread can't?
>>
>> thanks.
>>
>
> $file_array = file($file_name);
>
> foreach ($file_array as $line_number => $line)
> {
> // Handle the line
> }
>
>
>
> See: http://us3.php.net/manual/en/function.file.php
What if the file is larger than memory_limit (8Mb)?
http://www.php.net/manual/en/ini.core.php#ini.memory-limit
fgets() is the right answer in this case.
So, instead of coding with file() which works now with a 200K file,
start with fgets and your script will not break when the file grows.
http://www.php.net/fgets
--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
[Back to original message]
|