CodeIgniter Forums
Database Utility Class - csv_from_result - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database Utility Class - csv_from_result (/showthread.php?tid=26526)



Database Utility Class - csv_from_result - El Forum - 01-15-2010

[eluser]mikepuerto[/eluser]
Any suggestions on how to prevent this from adding the delimiter to the last field on a line?

Example, the output is:

field1,field2,field3,field4,

need to get rid of the last comma on the line.

Thanks!


Database Utility Class - csv_from_result - El Forum - 01-15-2010

[eluser]brianw1975[/eluser]
lol it's stupid simple, i struggled with it for a long time too and found it mindbogbling infuriating how easy it actually is, it's so easy I had to look it up! lol

// remove the trailing commas
$str = substr($str,0,-1);


Database Utility Class - csv_from_result - El Forum - 01-17-2010

[eluser]mikepuerto[/eluser]
Awesome! Thnx!