Skip to content

Instantly share code, notes, and snippets.

@dertajora
Last active May 7, 2021 00:38
Show Gist options
  • Save dertajora/91c57afde968a610dbf796e50bfa22f3 to your computer and use it in GitHub Desktop.
Save dertajora/91c57afde968a610dbf796e50bfa22f3 to your computer and use it in GitHub Desktop.

Revisions

  1. dertajora revised this gist Jul 17, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion save_to_csv.php
    Original file line number Diff line number Diff line change
    @@ -19,4 +19,6 @@
    foreach ($data as $row)
    {
    fputcsv($file, $row);
    }
    }

    ?>
  2. dertajora revised this gist Jul 17, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions save_to_csv.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    // this script would save csv file to this specified directory
    // APPPATH is location of application folder in Codeigniter
    $file = fopen(APPPATH . '/../upload/'.'tesaasasat.csv', 'wb');
  3. dertajora created this gist Mar 2, 2017.
    21 changes: 21 additions & 0 deletions save_to_csv.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    // this script would save csv file to this specified directory
    // APPPATH is location of application folder in Codeigniter
    $file = fopen(APPPATH . '/../upload/'.'tesaasasat.csv', 'wb');

    // set the column headers
    fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));

    // Sample data. This can be fetched from mysql too
    $data = array(
    array('Data 11', 'Data 12', 'Data 13', 'Data 14', 'Data 15'),
    array('Data 21', 'Data 22', 'Data 23', 'Data 24', 'Data 25'),
    array('Data 31', 'Data 32', 'Data 33', 'Data 34', 'Data 35'),
    array('Data 41', 'Data 42', 'Data 43', 'Data 44', 'Data 45'),
    array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55')
    );

    // output each row of the data
    foreach ($data as $row)
    {
    fputcsv($file, $row);
    }