I have an array coming into a function that looks something like this:
$array = array(
'SomeKey' => array()
'SomeOtherKey' => array()
);
and I would like to have the csv file, when opened in excel, look like:
SomeKey
---- rows of data -----
SomeOtherKey
---- Rows of Data ---
the function I wrote only processes arrays of this matter:
$array = array(array(...));
public function createCvsObject($array, $name = 'report.csv'){
$this->headers($name);
if (count($array) == 0) {
return null;
}
$df = fopen("php://output", 'w');
fputcsv($df, array_keys(reset($array)));
foreach ($array as $row) {
fputcsv($df, $row);
}
fclose($df);
}
What would I have to change to get the expected out put I want?