How to remove the (\\)
backslash on a string? when using echo json_encode()
?
For example:
If you using PHP 5.2, json_encode just expect only 1 parameter when call it. This is an alternative to unescape slash of json values:
stripslashes(json_encode($array))
Don't use it if your data is complicated.
json_encode($response, JSON_UNESCAPED_SLASHES);
Yes it's possible. Look!
$str = str_replace('\\', '', $str);
But why would you want to?
Simpler way would be
$mystring = json_encode($my_json,JSON_UNESCAPED_SLASHES);