By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Remove the last comma

100+
P: 190
Hi

I have this (for sampple)

abc,cde,efg,ghc,

How can i remove this last ,

I knew there is a option using reqular expreesion but could not find the answer....
Aug 21 '08 #1
Share this Question
Share on Google+
3 Replies


100+
P: 190
Sorry guys i got the answer


use like this

$string=eregi_replace(',$', '', $string);
Aug 21 '08 #2

P: 14
you can also do this in following way.

$String = substr($String, 0, strlen($String) - strlen(','));
Aug 21 '08 #3

FLEB
P: 30
You can also do it with rtrim:

[PHP]rtrim($string, ',');[/PHP]
Aug 21 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.