user5191822
user5191822

Reputation:

rtrim <br /> when the last char is r

i have a problem with rtrim when the last character is r :

$str = 'En mille morceaux sur le sol<br/>Donc, je peux chasser les lucioles<br/>Je fais face à la douleur, c\'est magnifique<br/>Je ne dois plus courir<br/>Je ne dois plus courir<br /><br />';
$result = rtrim ($str, '<br />');

echo $result;
// En mille morceaux sur le sol<br/>Donc, je peux chasser les lucioles<br/>Je fais face à la douleur, c'est magnifique<br/>Je ne dois plus courir<br/>Je ne dois plus couri

so it misses the final r, thank's for the help

Upvotes: 0

Views: 58

Answers (1)

lenz
lenz

Reputation: 5817

The second argument to rtrim is not a substring. Rather, all combinations of the given characters are removed, regardless of their order. For example,

$result = rtrim ($str, ' /<>br');

would give you the same result. Because, starting from the end, characters are removed from the string until a character is encountered which is not in the given string.

Upvotes: 1

Related Questions