Remove backslash from string
Posted: 05 Nov 2020, 14:16
How can I remove backslashes from string in php?
I tried the following code.
But as you can see, it returns a different result.
I tried this code with simple str_ireplace():
But it returns:
Maybe it's something simple, but, how can I remove the backslash from string in php?
From 'abc-\123' I want to get 'abc-123'.
I tried the following code.
Code: Select all
$str ='abc-\123';
$str = stripcslashes($str);
echo $str; // abc-S
I tried this code with simple str_ireplace():
Code: Select all
$str ='abc-\123';
$str = str_ireplace('\', '', $str);
echo $str; // Error
Code: Select all
Parse error: syntax error, unexpected '', $str);
From 'abc-\123' I want to get 'abc-123'.