私はいくつかのGravity Formsエントリを取得しようとしており、そこから特定のデータをCSVにエクスポートしようとしています。PHPからCSVへ:特定のフィールドのみのエクスポート
私はテスト中に画面にエコーアウトすることができます。また、下記の静的テストデータ($ contents配列に格納されています)をCSVにエクスポートすることもできます。しかし、私はエクスポートする必要がある特定のフィールドをエクスポートしようとして立ち往生しています。
// 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', '[email protected]', 0, 0],
[2014, 6, '1st half', '[email protected]', 0, 0],
[2014, 6, '1st half', '[email protected]', 0, 0],
[2014, 6, '1st half', 'tim', 0, 0]
];
fputcsv($output_handle, $csv_headers);
foreach ($contents as $content) :
fputcsv($output_handle, $content);
endforeach;