Parse CSV Files

Parse CSV Files

Language:: PHP
Type:: snippet Back-end

Description:: CSV (Coma separated values) files are an easy way to store data, and parsing them using PHP is dead simple. Don’t believe me? Just use the following snippet and see for yourself.

$fh  = fopen("contacts.csv", "r");
while($line  = fgetcsv($fh, 1000, ",")) {
    echo  "Contact: {$line[1]}";
}

Source: http://phpbuilder.com/columns/Jason_Gilmore060210.php3?page=1