Blame view
downloadData.php
636 Bytes
670b6d6f8
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php // $data = json_decode($_POST['data'], true); $data = $_POST['data']; $arrayData = explode('|',$data); array_to_csv_download($arrayData, "3dHouse.csv"); function array_to_csv_download($array, $filename = "3dHouse.csv", $delimiter=",") { header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="'.$filename.'";'); // open the "output" stream // see http://www.php.net/manual/en/wrappers.php.php#refsect2-wrappers.php-unknown-unknown-unknown-descriptioq $f = fopen('php://output', 'w'); foreach ($array as $line) { fputcsv($f, explode(',',$line)); } } ?> |