I have a CSV file that looks like:
Name, Id, Address, Place,
John, 12, "12 mark street", "New York",
Jane, 11, "11 bark street", "New York"...
I have about 500 coloumns. I would like to convert this to JSON, but I want the output to look like:
{
"name": [
"John",
"Jane"
],
"Id": [
12,
11
],
"Address": [
"12 mark street",
"12 bark street"
],
"Place": [
"New York",
"New York"
]
}
Using PHP, how can I iterate through the CSV file so that I can make each column in the first row an array that holds the values in the same column on all the other rows?