- function generatedCsv($data, $delimiter = ',', $enclosure = '"') {
- $handle = fopen('php://temp', 'r+');
- foreach ($data as $line) {
- fputcsv($handle, $line, $delimiter, $enclosure);
- }
- rewind($handle);
- while (!feof($handle)) {
- $contents .= fread($handle, 8192);
- }
- fclose($handle);
- return $contents;
- }
复制代
使用法:
-
- $data[0] = "リンゴ";
- $data[1] = "オレンジ";
- generateCsv($data, $delimiter = ',', $enclosure = ' "');
- ?>
复制代
|