问题
I am using the following function to export to CSV.
$this->dbutil->csv_from_result()
Unfortunately at the end of the line it prints delimiter, When I use CSV to import data again it takes it as a field with out key. example are here:
"id", "time", "name",
"1", "1400000000", "John",
"2", "1400000000", "Matt",
Wondering if anybody can help with this.
回答1:
You can simply use
rtrim($string, ","); // this will strip the comma from the end of the string
Example :
$string = "abc" ;
echo rtrim( $string , "c") ;
It will echo ab
来源:https://stackoverflow.com/questions/24426598/codeigniter-this-dbutil-csv-from-result-ignore-last-delimiter