generate functionFri, 27 Jan 2023

import csv from local file and store all line in array. Loop on the array to get all specific columns

<?php $filename = 'data.csv'; $csv = array_map('str_getcsv', file($filename)); array_walk($csv, function(&$a) use ($csv) {$a = array_combine($csv[0], $a);}); array_shift($csv); # remove column header foreach ($csv as $row) { $company_name = $row['Company Name']; $first_name = $row['First Name']; $last_name = $row['Last Name']; } ?>

Questions about programming?Chat with your personal AI assistant