Notes

Note:
Possible gotcha: removing middle characters

Because trim() trims characters from the beginning and end of
a string, it may be confusing when characters are (or are not) removed from
the middle. trim('abc', 'bad') removes both 'a' and 'b' because it
trims 'a' thus moving 'b' to the beginning to also be trimmed. So, this is why it "works"
whereas trim('abc', 'b') seemingly does not.

See Also

ltrim() - Strip whitespace (or other characters) from the beginning of a string

rtrim() - Strip whitespace (or other characters) from the end of a string

str_replace() - Replace all occurrences of the search string with the replacement string