Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. function writecsv(){
  4. $list = array (
  5. array('aaa', 'bbb', 'ccc', 'dddd'),
  6. array('123', '456', '789'),
  7. array('"aaa"', '"bbb"')
  8. );
  9. $file = fopen('file.csv', 'w');
  10. var_dump($file);
  11. foreach ($list as $fields) {
  12. fputcsv($file, $fields, ";");
  13. }
  14. fclose($file);
  15. }
  16. if (isset($_GET['file'])) {
  17. header('Content-Disposition: attachment; filename="abc.csv"');
  18. readfile('file.csv');
  19. } else {
  20. echo "Funkcja zapisuje tablice do pliku file.csv na serwerze.\n Plik ma taka zawartosc jak trzeba.\n";
  21. echo "<a href=\"?file=1\">Link</a>";
  22. writecsv();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement