I'd like to find a match of a string in a CSV file in PHP 5.
There is, for me, 2 ways to do it :
- First : Get all occurences from the csv file, then check if my string exist in the array.
- Second : For each line of my CSV file, check if it matches. If it does, end the loop.
Which is the best way to do it ? There is a lot of line in my CSV file so I care about performance.
If you know some clues about it, I'll be glad to heard it :)
firstapproach is basicallysecondin a loop, it should be pretty clear what makes more sense in terms of performance and resource usage w/o need to ask here.fgetcsvreads single lines of data to begin with, so breaking out of the loop when you found what you need would be quite easy using that one.