Page 1 of 1

Cutting a String

Posted: Tue Feb 19, 2008 6:47 pm
by aliasxneo
It's pretty late and my mind is starting to go numb. I can't remember how to cutoff the last character in a string. I have a comma delimited list that always has a stray comma at the end that I want to cut off. Can someone help me out really quick with the function to do this? Thanks.

Re: Cutting a String

Posted: Tue Feb 19, 2008 6:48 pm
by Benjamin
If it's always a comma just use ltrim()

Re: Cutting a String

Posted: Tue Feb 19, 2008 6:53 pm
by aliasxneo
astions wrote:If it's always a comma just use ltrim()
That's what I was trying to think of. Thanks :p

And this can be closed.

Re: Cutting a String

Posted: Wed Feb 20, 2008 9:14 am
by Zoxive
Alternate way is substr()

Code: Select all

$Str = substr("abcdef", 0, -1);
echo $Str;
// abcde