Removing the last space in a string


I have to remove the last space from a string


so, essentially id like my string to end up as:


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?


Using PHP, the rtrim() function is probably what you need.

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

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

Leave a Reply

(*) Required, Your email will not be published