0
如何将我的循环合并到CSV文件中导出?导出CSV文件下载文章
<?php $answers = new WP_Query(array('cat' => 25, 'order' => 'DESC')); ?>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td valign="top">Name</td>
<td valign="top">Submission/production title</td>
<td valign="top">Performance space</td>
</tr>
<?php if ($answers->have_posts()) : while ($answers->have_posts()) : $answers->the_post(); ?>
<tr>
<td><?php echo the_title(); ?></td>
<td><?php echo the_field('submit_submission_production_title'); ?></td>
<td><?php echo the_field('submit_performance_space'); ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
我该如何与fputcsv合并?
<?php
$list = array (
'aaa,bbb,ccc,dddd',
'123,456,789',
'"aaa","bbb"'
);
$fp = fopen('file.csv', 'w');
foreach ($list as $line) {
fputcsv($fp, split(',', $line), ',', '"');
}
fclose($fp);
?>
感谢这个,我给它一个去。那么我怎么能把它放在一个链接中,说“下载文件”,这样它可以保存为CSV? – Rob
我不太清楚如何处理'fputcsv'和'fclose',但我认为这很容易,很可能,答案是在这个庞大的存储库中搜索;) – brasofilo