function download($type) { global $variables; $year = 2015; //TODO getElectionYear $path = $variables['pathForCSVandJson']; $output = ""; if ($type == 'csv') { $output .= getResultsOutputCsv(); } elseif ($type == 'json') { $output .= getResultsOutputJsn(); } $file = fopen($path . "/ptonElections_" . $year . "." . $type, "w"); if ($file) { fwrite($file, $output); fclose($file); } return $output; }
function download() { $output = getResultsOutputCsv(); // Download the file $handle = fopen("/Users/Anouk/testdata/election_results.csv", "w"); if ($handle) { fwrite($handle, $output); fclose($handle); } echo $output; exit; }