note 44265 deleted from function.explode by aidan
| From: | aidan@php.net | Date: | Tue, 20 Jul 2004 01:12:05 +0000 |
| Subject: | note 44265 deleted from function.explode by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73661@lists.php.net to get a copy of this message | ||
Note Submitter: krysits@oto.lv
----
/*
I often use this function to export one or two dimensional array to excel spreadsheet.
*/
function export2excel($arr=NULL,$name='export'){
if(is_array($arr) && count($arr)){
$x='';
foreach($arr as $key=>$value){
if(is_array($value)){
foreach($value as $key1=>$value1)
$x.="\\"".$value1."\\"\\t";
$x.="\n";
}
else $x.="\\"".$value."\\"\\n";
}
header("Content-Type: application/vnd.ms-excel;
name='excel'");
header("Content-disposition: attachment;
filename=".$name.".xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");;
echo $x;
die();
}
else return NULL;
}