CSV zu Assot PHP
<?php
//Map lines of the string returned by file function to $rows array.
$rows = array_map(function($employee){return explode(",",$employee); }, file('employees.csv'));
//Get the first row that is the HEADER row.
$header_row = array_shift($rows);
//This array holds the final response.
$employee_csv = array();
foreach($rows as $row) {
if(!empty($row)){
$temp = [];
//Loop through the individual attributes in the row and map it to a corresponding header.
for($i =0; $i < count($row); $i++)
{
$temp[$header_row[$i]] = $row[$i];
}
//Push the row to the employees array.
array_push($employee_csv,$temp);
}
}
print_r($employee_csv)
?>
Prickly Piranha