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?

Jack Maessen
  • 1,780
  • 4
  • 19
  • 51

1 Answers1

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

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46