Why does rtrim remove things that aren't on the right?

  • A+
$word = "shshsh.shshsh"; print(rtrim($word, "sh.")); 

Output is an empty string when I would have expected it to output the entire string (since "sh." does not appear at the end in this case).


The "sh." is a set of characters rather than a string to remove. It'll remove characters from the end of the $word recursively as long as it's a character in [s, h, .], until it hits one that isn't in this list, essentially removing everything in your case.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: