/** * Export tabular data to CSV-file * @param array $data * @param string $filename */ public static function export_table_csv_utf8($data, $filename = 'export') { if (empty($data)) { return false; } $path = Chamilo::temp_file(); $converter = new Utf8Encoder(null, true); $file = FileWriter::create($path, $converter); $file = CsvWriter::create($file); foreach ($data as $row) { $file->put($row); } $file->close(); DocumentManager::file_send_for_download($path, false, $filename . '.csv'); unlink($path); exit; }