script doesn't finish displaying large txt file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

script doesn't finish displaying large txt file

Post by jaymoore_299 »

I have a very large txt file that I use as a database on my local computer and use a php script to manipulate it.
I was running this through the apache server and loading a script in my
"http://localhost/dev/" directory, which basically reads all lines and prints only a certain field from each of the lines.
However when I run this it seems to read the file's contents fine but when it comes to printing all the specific fields, most of the time it does not finish printing past the half point. After reloading the page several times, I'd get varying results, sometimes printing more, sometimes less, but most of the time falling short of printing all the specific fields. What's going on here?

Code: Select all

$contents=file('C:/bigtextfile.txt');
$line=array();
foreach ($contents as $v)
{
$line[]=explode("|",$v);
}
foreach ($line as $v)
{
print $v[0];
}
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

Post by jaymoore_299 »

and the file in question has lines of data like this
http://www.domain.com/etc|field2|field3

and has a lot of gaps in between many of the lines.
Post Reply