generate functionFri, 27 Jan 2023

import csv from local file and put values into an array, remove header line, and loop through the array

function get_csv() { $file = fopen("data.csv","r"); while(! feof($file)) { $data[] = fgetcsv($file); } fclose($file); return $data; } function loop_csv() { $data = get_csv(); $count = count($data); for ($x=1; $x<$count; $x++) { echo $data[$x][0].", ".$data[$x][1].", ".$data[$x][2]."<br>"; } } loop_csv();

Questions about programming?Chat with your personal AI assistant