note 44265 added to function.explode
| From: | krysits at oto dot lv | Date: | Tue, 20 Jul 2004 00:33:16 +0000 |
| Subject: | note 44265 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73660@lists.php.net to get a copy of this message | ||
/*
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44265
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44265&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44265&report=yes
Search -- http://master.php.net/manage/user-notes.php