Cutting a String

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

Cutting a String

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Cutting a String

Post by Benjamin »

If it's always a comma just use ltrim()
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

Re: Cutting a String

Post 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.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Cutting a String

Post by Zoxive »

Alternate way is substr()

Code: Select all

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