ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ $csv = ""; foreach ($data as $row) { $csv .= join(",", $row) . "n"; } echo $csv; ?> <?php function toCSV(array $data, array $colHeaders = array(), $asString = false) {     $stream = ($asString)      ? fopen("php://temp/maxmemory", "w+")      : fopen("php://output", "w");     if (!empty($colHeaders)) {         fputcsv($stream, $colHeaders);     }     foreach ($data as $record) {         fputcsv($stream, $record);     }     if ($asString) {         rewind($stream);         $returnVal = stream_get_contents($stream);         fclose($stream);         return $returnVal;     }     else {         fclose($stream);     } } ~~~