View Single Post
Old 07-24-2009, 06:51 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Ok, a few points.
  1. The line with fopen() is doing absolutely nothing useful in that script. It is the call to the file() function that brings in the file, fopen isn't needed.
  2. To use file_get_contents to grab a file just use $content = file_get_contents($filename); along with that third line. That will do what the code snippet you showed does.
  3. You're wanting to parse CSV data please don't try and do it manually: PHP has a built-in function called fgetcsv or it is super-easy to use SplFileObject::fgetcsv (see the 2nd example in particular).
Salathe is offline  
Reply With Quote