Some questions about file_get_contents
View Single Post
07-24-2009, 08:49 PM
Join Date: Sep 2007
Originally Posted by
Ok, a few points.
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.
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.
You're wanting to parse CSV data please don't try and do it manually: PHP has a built-in function called
or it is super-easy to use
(see the 2nd example in particular).
Salathe, that SplFileObject::fgetcsv looks pretty awesome! Thanks for the help, I'm going to give it a try now
View Public Profile
Send a private message to Sam Granger
Find More Posts by Sam Granger