• Removing text from the end of a Variable
    6 replies, posted
I need some help with a variable. I need a way of removing something from the end of it. The code I'm using right now outputs "var1, var2,". Is there anyway I can remove the ',' from the end of 'var2,'?
What language?
preg_replace/ereg_replace might help you [editline]07:29PM[/editline] [quote=efex;17603245]what language?[/quote] php
[php]trim('var1, ', ' ,');[/php] or [php]rtrim('var1, ', ' ,');[/php]
Fixed it, used an x loop to make sure there wasn't an extra comma at the end.
[url]http://uk3.php.net/implode[/url]
[url]http://www.php.net/substr[/url] [code]$rest = substr("abcdef", 0, -1); // returns "abcde"[/code]
Sorry, you need to Log In to post a reply to this thread.