pioneerx01 Posted March 1, 2011 Share Posted March 1, 2011 I have sen this function before but can not remember what it is or how to code it. It allows you remove only defined characters from the end of the string. I am not looking to replace any occurrence anywhere in the phrase, just the end. For example lets say I want to remove"ld!" from phrase "Hello World!" That function would return "Hello Wor" Thanks Link to comment https://forums.phpfreaks.com/topic/229200-function-to-remove-predifined-characters-from-the-end-of-the-string/ Share on other sites More sharing options...
litebearer Posted March 1, 2011 Share Posted March 1, 2011 may get you there - http://php.net/manual/pt_BR/function.substr.php Link to comment https://forums.phpfreaks.com/topic/229200-function-to-remove-predifined-characters-from-the-end-of-the-string/#findComment-1181073 Share on other sites More sharing options...
kenrbnsn Posted March 1, 2011 Share Posted March 1, 2011 The rtrim() function works fine for this: <?php $str = 'Hello World!'; echo rtrim($str,'ld!'); ?> Ken Link to comment https://forums.phpfreaks.com/topic/229200-function-to-remove-predifined-characters-from-the-end-of-the-string/#findComment-1181088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.