[Solved] Removing the end of 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
jimbo
Forum Newbie
Posts: 5
Joined: Wed Feb 23, 2005 12:01 pm

[Solved] Removing the end of a string

Post by jimbo »

sorry guys, last one for today, promise!

String one: "billybobjoeisthecoolestguyever"
String two: "isthecoolestguyever"
Desired String: "billybobjoe"

I know that the desired string will be the first string minus the second string.
does anyone know how to remove the second string from the end of the first?
Last edited by jimbo on Wed Feb 23, 2005 12:58 pm, edited 1 time in total.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

substr() does all the work.
jimbo
Forum Newbie
Posts: 5
Joined: Wed Feb 23, 2005 12:01 pm

Post by jimbo »

substr requires the length to be truncaded. how can I get the length of the second string?

I need a function that gives me the length of $stringtwo
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hmmm strlen() maybe? :roll:
jimbo
Forum Newbie
Posts: 5
Joined: Wed Feb 23, 2005 12:01 pm

Post by jimbo »

thanks guys,

[topic solved]
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Reading the manual is your friend. It is everyone elses who programs PHP.
Post Reply