Issue
I have to remove the last space from a string
(\s)a(\s)b(\s)
so, essentially id like my string to end up as:
(\s)a(\s)b
just to be clear, id prefer searching against ‘ ‘ instead of performing a regex expression, but i used regex patterns so you could understand the spaces.
How do I do this using php
?
Solution
Using PHP, the rtrim()
function is probably what you need.
rtrim — Strip whitespace (or other characters) from the end of a string
http://www.php.net/manual/en/function.rtrim.php
Answered By – Jim Frenette
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0