Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Read CSV file

  • fgetcsv

fgetcsv returns an array of the values.


<?php
    $fd = fopen("data/fields.csv", "r");
?>

<table border="1">
<?php
    while ($a = fgetcsv($fd, 80)) {  # read a csv file and split it up.
        if (!empty($a[0])) {
            print "<tr><td>$a[0]</td><td>$a[1]</td></tr>\n";
        }
    }
?>
</table>