Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cria um Array
- $list = array ();
- // Inclui os resultados no array
- array_push($list, array("## START OF USER TABLE ##"));
- while ($row = $result_users->fetch(PDO::FETCH_ASSOC)) {
- array_push($list, array_values($row));
- }
- array_push($list, array("## END OF USER TABLE ##"));
- // Gera o .csv
- $fp = fopen('php://output', 'w');
- header('Content-Type: text/csv');
- header('Content-Disposition: attachment; filename="'.$filename.'"');
- foreach ($list as $ferow) {
- fputcsv($fp, $ferow);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement