function downloadCSV($info, $header, $filename, $options = array()) { global $Opt; if (defval($options, "type", "csv") == "csv" && !isset($Opt["disableCsv"])) { $csvt = CsvGenerator::TYPE_COMMA; } else { $csvt = CsvGenerator::TYPE_TAB; } if (get($options, "always_quote")) { $csvt |= CsvGenerator::FLAG_ALWAYS_QUOTE; } if (get($options, "crlf")) { $csvt |= CsvGenerator::FLAG_CRLF; } $csvg = new CsvGenerator($csvt); if ($header) { $csvg->set_header($header, true); } if (get($options, "selection")) { $csvg->set_selection($options["selection"] === true ? $header : $options["selection"]); } $csvg->download_headers($Opt["downloadPrefix"] . $filename . $csvg->extension(), !get($options, "inline")); if ($info === false) { return $csvg; } else { $csvg->add($info); if (get($options, "sort")) { $csvg->sort($options["sort"]); } $csvg->download(); exit; } }