Archive for June 2005

Let's assume we have a file "users.csv", containing the following data:

"Username","Firstname","Lastname","Age"
"johndoe","John","Doe","21"
"hmiller","Hank","Miller","35"

Processing the data in PHP is rather straight forward, by simply using fgetcsv(). Let's display the user's name and age:

// open the file for reading
$f = fopen('users.csv', 'r');

// just a dummy read to get the header out of the way
fgetcsv($f);

// loop through each line
while ($data […]