PHP5: Lire et Afficher un fichier CSV

Author:


Download

<?php

class ClasseLec
{

static function lireCSV($fichierCSV)
{

$fh = fopen($fichierCSV, 'rb');
if (! $fh)
{
    die("Impossible d'ouvrir $fichierCSV: $php_errormsg");
}

print "<table>";

for ($line = fgetcsv($fh, 1024); ! feof($fh); $line = fgetcsv($fh, 1024)) {
    print '<tr><td>' . implode('</td><td>', $line) . "</td></tr>
";
}

print '</table>';
}

}

ClasseLec::lireCSV("fichier.csv");
?>

Leave a Reply

Your email address will not be published. Required fields are marked *


8 + nine =