I wrote a script to test different ways to do this and was surprised at some of the results. Both the "fgets()" and "file()" methods (along with "stream_get_line()" on v.5), compared to "fgetcsv()", came out way faster on Windows, running in 1/5 to 1/4 the time. I expected the other way around. On Linux it was pretty much a wash, all coming within 10% of each other. That surprised me a little, too. This was with a local text file; the results with a remote file, although they varied quite a bit, were generally the same. BTW, using "explode()" was a lot faster than using "split()" (taking 1/3 the time).
If anyone is interested and wants to check the code for me (I'm not an expert speed-tester) or try it themselves, just say so and I'll post it.
Given all that, I think you'll find a great improvement doing it like this:
while (!feof($fp)) {
$fields = fgetcsv($fp, 512, "\t");
if ($fields[14] == $find) {
$found = true;
$price = fields[10];
break;
}
}
Or, on Windows:
while (!feof($fp)) {
$line = fgets($fp, 512);
$fields = explode("\t", $line);
if ($fields[14] == $find) {
$found = true;
$price = fields[10];
break;
}
}