Php_exceloutput.php
'Tom ', 'age' => 61, 'date' => '2017-09-24 12:00:00'), array ('name' => 'Mark ', 'age' => 25, 'date' => '2017-09-23 11:00:00 '), array ('name' => 'Lucy', 'age' => 43, 'date' => '2014-09-22 10:00:00 '),); $ title = array ('name', 'age', 'time ',); exportexcel ($ data, $ title); die (); /*** export excel ** @ param array $ data dataset * @ param array $ title set * @ param string $ excel file name exported by filename */function exportexcel ($ data = array (), $ title = array (), $ filenam E = 'report') {header ("Content-type: application/vnd. ms-excel "); header (" Content-Disposition: filename = ". $ filename. ". xls "); // export the xls to start if (! Empty ($ title) {foreach ($ title as $ k => $ v) {$ title [$ k] = iconv ("UTF-8", "GBK ", $ v) ;}$ title = implode ("\ t", $ title); echo "$ title \ n" ;}if (! Empty ($ data) {foreach ($ data as $ key => $ val) {foreach ($ val as $ ck => $ cv) {$ data [$ key] [$ ck] = iconv ("UTF-8", "GBK", $ cv );} $ data [$ key] = implode ("\ t", $ data [$ key]);} echo implode ("\ n", $ data );}}