string { $stream = fopen('php://temp', 'w'); fputcsv($stream, $header); foreach ($items as $item) { fputcsv($stream, $item->toCsvRow()); } rewind($stream); $contents = stream_get_contents($stream); if ($convert) { return mb_convert_encoding($contents, 'SJIS', 'UTF-8'); } return $contents; }