How to remove \ from links I got from scraping.
Example:
https:\\/\\/graph.facebook.com\\/v1.0\\/159463177547058\\/photos?fields=source\u00252Cname&limit=100&after=MjA4MTA5NTMyNjgyNDIy
Is there any way?
How to remove \ from links I got from scraping.
Example:
https:\\/\\/graph.facebook.com\\/v1.0\\/159463177547058\\/photos?fields=source\u00252Cname&limit=100&after=MjA4MTA5NTMyNjgyNDIy
Is there any way?
Try feeding it into stripslashes()
.
$no_slashes_url = stripslashes("https:\/\/graph.facebook.com\/v1.0\/159463177547058\/photos?fields=source\u00252Cname&limit=100&after=MjA4MTA5NTMyNjgyNDIy");
This is an escaped sequence where special symbols are replaced by it's escape equivalent.
Usually, you can revert this by using stripslashes()
. Howover, this escape sequence uses \u
for UNICODE symbols which is not supported by PHP.
But you can use this little hack instead:
$raw = "https:\\/\\/graph.facebook.com\\/v1.0\\/159463177547058\\/photos?fields=source\u00252Cname&limit=100&after=MjA4MTA5NTMyNjgyNDIy";
$url = json_decode('"'.$raw.'"');
This function converts UNICODE escaped symbols into it's UTF-8 equivalents. Only because this is an URL we can trust those UNICODE escaped sequences will be safely converted to ASCII without issues, preserving the URL functionality.
str_replace()
would be a good place to start