I am trying to remove all backslashes from a url-decoded string, but it is outputting \ rather than outputting the url-decoded string with \ removed.
Please can you tell me my problem.
<?php
$json = $_GET['ingredients'];
echo urldecode(str_replace($json,$json, "\\"));
?>
You want to use stripslashes()
, because that's exactly what it is for. Also looks shorter:
echo urldecode(stripslashes($json));
You should however consider disabling magic_quotes rather.