I have a variable which contains a path in json_encode
/users/crazy_bash/online/test/
but json_encode converts the path to this:
\/users\/crazy_bash\/online\/test\/
Why? How can i display a normal path?
the code
$pl2 = json_encode(array(
'comment' => $nmp3,
'file' => $pmp3
));
echo($pl2);
It’s perfectly legal JSON, see http://json.org/.
\/is converted to/when unserializing the string. Why worry about it if the output is unserialized by a proper JSON parser?If you insist on having
\/in your output, you can usestr_replace():Note that it’s still valid JSON by the definition of a string:
(source: json.org)