In a string that includes quotes, I always get an extra whitespace before the end quote. For instance
"this is a test " (string includes quotes)
Note the whitespace after test but before the end quote. How could I get rid of this space?
I tried rtrim but it just applies for chars at the end of the string, obviously this case is not at the end.
Any clues? Thanks
Here's another way, which only matches a sequence of spaces and a quote at the end of a string...
$str=preg_replace('/\s+"$/', '"', $str);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With