Last active
August 21, 2019 20:33
-
-
Save BlackScorp/21f1ec660f13664ee864e383b8b4050c to your computer and use it in GitHub Desktop.
Beispiel Code für das Youtube Video https://youtu.be/vE7AXqs2dKk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(-1); | |
ini_set('display_errors', 'On'); | |
$array = [ | |
['Row 1','Row 2','Row 3'], | |
['Col 1','Col 2','Col 3'], | |
['Col 1','Col 2','Col 3'], | |
]; | |
$file = new SplTempFileObject(); | |
foreach($array as $row){ | |
$file->fputcsv($row); | |
} | |
$file->rewind(); | |
header("Content-Type: text/csv"); | |
header('Content-Disposition: attachment; filename="temp.csv"'); | |
$file->fpassthru(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment