force file download csv php code example
Example: php force download csv
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="ramais.csv"');
$saida = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "id;nome;ramal;email;setor;diretor\r\n";
foreach ($saida as $s){
foreach ($s as $k => $v){
echo "{$v};";
}
echo "\r\n";
}