fork download
  1. <?php
  2. $export = array
  3. (
  4. "head" => array
  5. (
  6. "ID",
  7. "Title"
  8. ),
  9. "body" => array
  10. (
  11. array(1, "lorem"),
  12. array(2, "Ipsum"),
  13. )
  14. );
  15.  
  16. header('Content-Type: application/force-download; name="test.xls"');
  17. header('Content-Transfer-Encoding: binary');
  18. header('Content-Disposition: attachment; filename="test.xls"');
  19. header('Expires: 0');
  20. header('Cache-Control: no-cache, must-revalidate');
  21. header('Pragma: no-cache');
  22. ?>
  23. <html>
  24. <head>
  25. <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
  26. </head>
  27. <body>
  28. <table>
  29. <thead>
  30. <tr>
  31. <?php foreach($export['head'] as $th) : ?>
  32. <th><?php echo $th; ?></th>
  33. <?php endforeach; ?>
  34. </tr>
  35. </thead>
  36. <?php if(!empty($export['body'])) : ?>
  37. <tbody>
  38.  
  39. <?php foreach($export['body'] as $tr) : ?>
  40. <tr>
  41. <?php foreach($tr as $td) : ?>
  42. <td><?php echo $td; ?></td>
  43. <?php endforeach; ?>
  44. </tr>
  45. <?php endforeach; ?>
  46. </tbody>
  47. <?php endif; ?>
  48. </table>
  49. </body>
  50. </html>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
<html>
	<head>
		<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
	</head>
	<body>
		<table>
			<thead>
				<tr>
										<th>ID</th>
										<th>Title</th>
									</tr>
			</thead>
						<tbody>
				
								<tr>
										<td>1</td>
										<td>lorem</td>
									</tr>
								<tr>
										<td>2</td>
										<td>Ipsum</td>
									</tr>
							</tbody>
					</table>
	</body>
</html>