Excel export
'Name', 'title' => 'title ') the key name is associated with the subelement key name of the following array $ data * @ param $ data array */public static function exportFile ($ fileName, $ title = '', $ firstRow = array (), $ data = array () {header ('content-Type: application/vnd. ms-execl '); header ('content-Disposition: attachment; filename = '. $ fileName. '.xls '); header ('pragma: no-cache'); header ('expires: 0'); if (! Empty ($ title) {echo self: excelExportIconv ($ title ). "\ t \ n";}/*** the first row is associated with the subsequent data by key name */if (! Empty ($ firstRow) & is_array ($ firstRow) {// output the first line of content foreach ($ firstRow as $ first) {echo self: excelExportIconv ($ first ). "\ t";} echo "\ n"; if (! Empty ($ data) & is_array ($ data) {foreach ($ data as $ item) {foreach ($ firstRow as $ _ key = >$ _ val) {if (isset ($ item [$ _ key]) {echo self: excelExportIconv ($ item [$ _ key]). "\ t";} else {echo self: excelExportIconv (''). "\ t" ;}} echo "\ n" ;}} else {if (! Empty ($ data) & is_array ($ data) {foreach ($ data as $ item) {foreach ($ item as $ val) {echo self :: excelExportIconv ($ val ). "\ t";} echo "\ n";} echo "\ n" ;}}}/ *** example: */$ fileName = 'example '; $ title = 'This is title'; $ firstRow = array ('id' => 'id', 'name' => 'name ', 'title' => 'title'); $ data = array ('id' => 1, 'name' => 'name 1 ', 'title' => 'Title 1'), array ('id' => 2, 'name' => 'name 2', 'title' => 'Title 2' ), Array ('id' => 3, 'name' => 'name 3', 'title' => 'Title 3 '), array ('id' => 4, 'name' => 'name 4', 'title' => 'Title 4'),); Excel_tool: exportFile ($ fileName, $ title, $ firstRow, $ data);?>