Can anyone tell me how I would remove a substring from the end of a string.
The string in question could have any one of three substrings at the end of it that need removed, so I wouldn't know in advance what the length was.
HelenLF
0
Junior Poster
Recommended Answers
Jump to Post$treplace = array("string1","string2","string3"); $twith=array("","",""); $done=str_replace($treplace,$twith,$origstring);
Like that? Or do you want it only replaced if it's at the end of the string? If you're looking for extensions, you might use the strrpos function and look for the '.' then use substr to remove everything after it.
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.