I want to read .csv file in PHP and put its contents into the database. I wrote the following code:
$row = 1;
$file = fopen(\"qryWebsite.csv\", \"r\");
while
If you're using the composer package manager, you can also rely on league/csv
According to theire documentation:
use League\Csv\Reader;
//load the CSV document from a file path
$csv = Reader::createFromPath('/path/to/your/csv/file.csv', 'r');
$csv->setHeaderOffset(0);
$header = $csv->getHeader(); //returns the CSV header record
$records = $csv->getRecords(); //returns all the CSV records as an Iterator object