xxBUCKSxx Posted December 14, 2008 Share Posted December 14, 2008 i'm using the rtrim command to trim some messy <br /> tags from the end of a string, and it's working fine except for when the string ends with a word end with the letter 'r' it decides to trim the last 'r' from the string too! is this normal and is there a work around? this is the string $ptext "Alan Butler<br /> v<br /> Wayne Fisher <br /><br />" This is the command $ptext = rtrim($ptext,"<br />" ); this is what it does $ptext "Alan Butler<br /> v<br /> Wayne Fishe" hope someone has seen this before and can help Link to comment https://forums.phpfreaks.com/topic/136953-solved-rtrim-is-removing-chars-i-dont-want-why-would-it-do-that/ Share on other sites More sharing options...
Mark Baker Posted December 14, 2008 Share Posted December 14, 2008 rtrim() is doing exactly what you're telling it to do, removing every character that is one of '<', 'b', 'r', ' ', '/' or '>' that it finds at the end of the string It removes a set of characters, not a string try using str_replace() of substr_replace() instead Link to comment https://forums.phpfreaks.com/topic/136953-solved-rtrim-is-removing-chars-i-dont-want-why-would-it-do-that/#findComment-715275 Share on other sites More sharing options...
xxBUCKSxx Posted December 15, 2008 Author Share Posted December 15, 2008 ah! thats why, I thought it would be simple many thanks mate Link to comment https://forums.phpfreaks.com/topic/136953-solved-rtrim-is-removing-chars-i-dont-want-why-would-it-do-that/#findComment-715627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.