I have following array:
categories = [
[0]=> array(2) {
["categoryTitle"]=> string(int)
["subCategories"]=> array(n) {
[0]=> string(int)
...
[n]=> string(int)
}
}
[1]=> array(2) {
["categoryTitle"]=> string(int)
["subCategories"]=> array(n) {
[0]=> string(int)
...
[n]=> string(int)
}
}
[n]=> array(2) {
["categoryTitle"]=> string(int)
["subCategories"]=> array(n) {
[0]=> string(int)
...
[n]=> string(int)
}
}
]
How do I correctly store this data into CSV file, so I could have following structure:
Category_table | SubCategories_table
categories[n]['categoryTitle'] | categories[n]['subCategories']
If I just run this:
$fp = fopen('categories.csv', 'w');
foreach ($categories as $category) {
fputcsv($fp, $category);
}
fclose($fp);
I end up with structure like this: first table has correct string(title of the category), but next table just has literally word array.
So how can I correctly store the subCategories
array in csv, in separate table column?