I\'m trying to get a multidimensional array into a csv file. data in the array is as such:
Array
(
[0] => Array
(
[product_id] => 1111
I would suggest to flatten each array first:
foreach ($csv as $file) {
$result = [];
array_walk_recursive($file, function($item) use (&$result) {
$result[] = $item;
});
fputcsv($output, $result);
}
In each iteration it would create an array like this:
[1111, 'Alcatel One Touch Idol 2', 'alcatel-one-touch-idol-2', 54, 42, ...]