Jump to content

[SOLVED] rtrim is removing chars I don't want! why would it do that??:)


xxBUCKSxx

Recommended Posts

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 ;D

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.