If you look at the
Documentation for fgetcsv(), You'll notice it says a few relevant things:
fgetcsv — Gets line from file pointer and parse for CSV fields
This pretty much states that fgetcsv only returns one line of the file- It starts from the last read part of the file, and reads until it hits a newline, the specified length, or the end of the file. This means you'll need to make a loop to iterate through each line of the file, and the easiest way to do that involves what the documentation says here:
fgetcsv() returns NULL if an invalid handle is supplied or FALSE on other errors, including end of file.
So, you can create a while loop that not only reads your next line, but checks for end of file as well. This can be done like so:
while (($line = fgetcsv($handle, 1000, ",")) !== FALSE) { // This will continue if $line was set to a valid value // Do what you want with $line here.
}
It might look a bit confusing, but it makes sense when you realize that the assignment operator returns the assigned value, which you can then check. The following illustrates that point (PHP Interactive shell):
php > if ($hi = "test") { echo "true"; }
true
php > if ($hi = "") { echo "true"; }
php >