Welcome Guest, Not a member yet? Register   Sign In
array to csv
#1

I want to convert a simple array to csv with csv_from_result, but I have this error:
 
You must submit a valid result object
 
I have no ideas
Reply
#2

(05-23-2018, 12:26 PM)lucavalentino Wrote: I want to convert a simple array to csv with csv_from_result, but I have this error:
 
You must submit a valid result object
 
I have no ideas

without the source code, we can not help.
Reply
#3

You can only use it with a database object.
https://www.codeigniter.com/userguide3/d...a-csv-file

You can use this function for turning a normal array into csv:
https://css-tricks.com/snippets/php/gene...rom-array/
Reply
#4

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);

return readCSV($nome_do_arquivo, $array_de_indices);
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB