I needed to remove all break line tags from the beginning and end of below string, but trim() function removes more than expected and I couldn’t work out the reason for this.
The reason this is happening is because trim removes characters from the beginning and end of a string, so your second argument is treated as a list of characters (<, b, r, , /, >) to remove… which includes the opening and closing chevron from the opening and closing strong tags respectively.
You could instead use the str_replace function to remove the br tags:
I would like to remove just those at the beginning and end of the string considering also that there might be some whitespaces in between br tags for example.