Loading CSV files into an array is something that comes up more times than I’d like to admit. Scrubbing mailing lists, loading flat files to a database and various other use cases are out there and fortunately, PHP makes it easy to to do.
There are a few ways to load files but the preferred method when you are uncertain what the format of the file will be would be to open a file pointer and use
fgetcsv() to grab each line. The reason for this is because CSV fields can have line breaks in them which would make
explode() bork the data.