downloadData.php 636 Bytes
<?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));
    }
}

?>