Skip to content

mohammad-ali238/csv-file-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV Reader

CSV file reader

Read CSV file with headers

Example file test.csv:

id;name;value
1;test1;value1
2;test2;value2

Read file (Example):

<?

$resource = fopen('test.csv','r');
$csv = new csv_reader($resource, false, ';');

// Get headers array
$csv->getHeaders(); // []
$first_row = $csv->current();
echo $first_row[0]; echo "<br>" . "\n"; // Headers

$counter = 0;
foreach ($csv as $row) {
    $counter++;
    if ($counter == 1) {
        continue;
    }
    echo $row[0]; echo "<br>" . "\n";
}

About

A PHP script for read any kind of CSV file data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages