I am trying to make CSV structure to import data to database using PHP.
I have title body and a field collection like: Friends:
name, email,number.
Friend fields is multiple. For example:
firstname, firsttest@test.com, 12225435
secondname, secondtest@test.com, 122234534
For title and body, i can manage easily but how can i manage for friends column in CSV.
Thanks
You can create a json string to store the friends column. For example, in the csv convert friends column values as {"firstname":test,"email":firsttest@test.com,"number":12225435} this will now be a separate column and store it in database in a text column. While retrieving the data you can decode the json to array.
For converting the friends column to json you can copy the csv data to excel sheet and apply the formula to convert friends column json and again save the excel as csv.