Read Data from CSV File using PHP

fgetcsv function

<?php

$fp = fopen('test.csv', 'rb');

$data = [];

$row = fgetcsv($fp);
while ($row !== false) {
    $data[] = $row;
    $row = fgetcsv($fp);
}

fclose($fp);

print_r($data);

Leave a Comment

Cancel reply

Your email address will not be published.