I am trying to export certain data from my PHP form to CSV. I can echo out to screen during testing and I can also export to CSV the static test data (stored in the $contents array) you see below. But I am stuck trying to export the certain fields that I only need to export.
This is my code
// How do I get this info into the CSV?
/*foreach ( $entries as $entry ) :
echo $entry['2'];
echo $entry['3'];
echo $entry['6'];
endforeach;*/
$csv_headers = [
'Organisation Name',
'Registered Charity Number',
'Address',
'Phone',
];
$contents = [
[2014, 6, '1st half', 'roland@fsjinvestor.com', 0, 0],
[2014, 6, '1st half', 'steve@neocodesoftware.com', 0, 0],
[2014, 6, '1st half', 'susanne@casamanager.com', 0, 0],
[2014, 6, '1st half', 'tim', 0, 0]
];
fputcsv($output_handle, $csv_headers);
foreach ( $contents as $content) :
fputcsv($output_handle, $content);
endforeach;