So you have a titled CSV file.
To read it, first convert the rows into an array:
$csv = array_map("str_getcsv", file($filename));
$head = array_shift($csv);
For conversion into an associative array:
$csv = array_map("array_combine", array_fill(0, count($csv), $head), $csv);
To generate the files:
foreach ($csv as $index => $row) {
file_put_contents("$index.json", json_encode($row));
}
Here the loop counter $index
is used for generating the filenames.
See the manual for explanations on:
If you did want something else, write a more precise question next time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…