0

when i want to echo data from json with a / in it, it puts a backslash for the /.

How to remove the backslash?

This:

$data = [ "actualdir" => "uploads/aaa" ]; echo json_encode($data); 

gives me this as output:

{"actualdir":"uploads\/aaa"} 

And it should be:

{"actualdir":"uploads/aaa"} 

How can i achieve this?

0

1 Answer 1

2

You can try using the JSON_UNESCAPED_SLASHES option for json_encode - viz:

echo json_encode( $data, JSON_UNESCAPED_SLASHES ); 

Many other additional options are available - read more at PHP.net

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.