Skip to content

Instantly share code, notes, and snippets.

@aleckyann
Created July 3, 2018 04:25
Show Gist options
  • Save aleckyann/67b2f1f08d6e34c35e113451e583d452 to your computer and use it in GitHub Desktop.
Save aleckyann/67b2f1f08d6e34c35e113451e583d452 to your computer and use it in GitHub Desktop.
gerando .csv
//EXEMPLO:
// QUERO PEGAR EQUIPAMENTOS DA TABELA EQUIPAMENTOS E GERA O .CSV :
function writeCSV($nome_do_arquivo, $array_de_arrays, $array_de_indices = array()) {
$arquivo = fopen(FCPATH.$nome_do_arquivo, 'w');
array_unshift($array_de_arrays, $array_de_indices);
foreach ($array_de_arrays as $array) {
fputcsv($arquivo, $array);
}
fclose($arquivo);
}
writeCSV(base_url('equipamentos.csv'), $this->get('equipamentos')->result_array());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment