Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. class CSVExportController extends Base_Controller {
  4.  
  5. function __construct($session = true) {
  6. parent::__construct($session);
  7. }
  8.  
  9. public function export($captions = array(), $data = array()){
  10.  
  11. header('Content-type: text/x-csv');
  12. header('Content-Disposition: attachment');
  13.  
  14. if (count($captions) == 0 ) {
  15.  
  16. return false;
  17. }
  18.  
  19. $rows = array();
  20.  
  21. $rows[] = $this->generate_caption_row($captions);
  22. foreach ($data as $record) {
  23. $rows[] = $this->generate_row($record, $captions);
  24. }
  25.  
  26. echo implode("\n", $rows);
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement