我开发了以下成员函数来下载带有表数据的csv文件。但是我也收到带有键的单行数据。如何仅逐行获取值(每一行中的每个记录)。请帮忙。
/**
* @Route("admin/newsletter/export", name="NewsLetterExport")
*/
public function NewsLetterExportAction(Request $request)
{
$subscriberObj = $this->getDoctrine()
->getRepository(NewsLetterEntity::class)
->findAll();
$data = $this->encode($subscriberObj);
$response = new Response($data );
$response->setStatusCode(200);
$response->headers->set('Content-Type', 'text/csv; charset=utf-8');
$response->headers->set('Content-Disposition', 'attachment; filename="export.csv"');
return $response;
}