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.

$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.

Great!
Thanks for the quick reply. That does exactly what I want.
The substrings in question only ever appear at the end of the string so this is fine as it is.
Thanks again.

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.