So I am needing all my array keys to be the first column(Column 0) in an excel spreadsheet and the values of the array will be used to fill in the rest of the columns of the csv file (Columns 1-5).
See below examples
Code:
$array = array();
foreach($k["Time)"] as $key => $value)
{
$array[] = [$value];
}
print_r($array);
$file = fopen('demosaved.csv', 'w');
fputcsv($file, array('Column 0','Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
$data = array_values($array);
foreach ($data as $row)
{
fputcsv($file, $row);
}
fclose($file);
I have also tried the below and receive this error, "Array to string conversion":
foreach($k["Time Series (1min)"] as $key => $value)
{
$array[] = [$key, $value];
}
var_dump($array);
$file = fopen('demosaved.csv', 'w');
fputcsv($file, array('Column 0','Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
$data = $array;
foreach ($data as $row)
{
fputcsv($file, $row);
}
fclose($file);
var_dump($array)? it will help immensely in finding where the issue is.