codeigniter $ this-> dbutil-> csv_from_result忽略最后一个分隔符 [英] codeigniter $this->dbutil->csv_from_result ignore last delimiter

查看:216
本文介绍了codeigniter $ this-> dbutil-> csv_from_result忽略最后一个分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下函数导出为CSV。

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,

"id", "time", "name",

1,1400000000,John,

"1", "1400000000", "John",

2,1400000000,Matt,

"2", "1400000000", "Matt",

想知道是否有人可以帮助您。

Wondering if anybody can help with this.

推荐答案

只需使用

rtrim($ string,,); //这将从字符串结尾剥离逗号

示例:

$string = "abc" ; 

echo rtrim( $string , "c") ; 

It will echo ab

这篇关于codeigniter $ this-&gt; dbutil-&gt; csv_from_result忽略最后一个分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆