I would like to remove the trailing backslash from a string without using stripslashes()
or str_replace()
. Ideally I would be able to use rtrim()
, but its something about the backslashes that has PHP freaking out.
$string = "This is my string\";
//iv'e tried with no success
$clean_string = rtrim($string, "\\");
$clean_string = rtrim($string, "\\\\");
Ideally the string would just read "This is my string" without the backslash at the end. I'm not entirely sure how to escape it properly, any help is much appreciated.