Import data from csv/xls file is a main requirement in most of
the web applications. We can do this simply by using the fgetcsv function in PHP.
Here is the code for it.
<?PHP
// Import csv - PHP $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } ?>
Try it !
No comments:
Post a Comment