Barebone\CSVReader

Source

<?php
// create fileobject
$file = new \SplFileObject(__DIR__. '/../config/csv_file.csv');
// create the CSV reader
$reader = new Barebone\Readers\CSV\CSVReader($file);
// print the headers (1st row)
print_r( $reader->getColumnHeaders() ) ;
// go over each row
foreach ($reader->getRows() as $row) {
    print_r($row);
    // $row will be an array containing the comma-separated elements of the line:
    // array(
    //   0 => 'James',
    //   1 => 'Bond'
    //   etc...
    // )
}
        

Result

Array ( [0] => kolom1 [1] => kolom2 [2] => kolom3 ) Array ( [0] => 1 [1] => 2 [2] => 4 ) Array ( [0] => a [1] => b [2] => c ) Array ( [0] => 1 [1] => 2 [2] => 4 ) Array ( [0] => a [1] => b [2] => c ) Array ( [0] => 1 [1] => 2 [2] => 4 ) Array ( [0] => a [1] => b [2] => c ) Array ( [0] => 1 [1] => 2 [2] => 4 ) Array ( [0] => a [1] => b [2] => c ) Array ( [0] => 1 [1] => 2 [2] => 4 )