<?php
$arr=array(
  array(1,2,3,4), 
  array(1,2,3,4)
  );

array_to_csv_download($arr,"numbers.csv");
 
function array_to_csv_download($array, $filename = "export.csv", $delimiter=",") {
    //header('Content-Type: application/csv');
    header('Content-Type: text/csv; charset=utf-8');
    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, $line, $delimiter);
    }
} 
?>