codeigniter $this->dbutil->csv_from_result ignore last delimiter

冷暖自知 提交于 2019-12-25 04:22:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!