Hey! 🙂 If you are encoding your Arrays to JSON in PHP using json_encode()
and the function adds backslash before your slashes, I’m gonna show you a quick fix.
This is my original code:
1 2 3 4 5 6 |
<?php $arr = array(); $arr['success'] = true; $arr['message'] = "Please enter email/phone number."; echo json_encode($arr); ?> |
And the result is:
{"success":true,"message":"Please enter email\/phone number."}
See the added backslash before the slash? Ugly, right? To avoid that, simply add the JSON_UNESCAPED_SLASHES
argument to your json_encode() function usage like this:
1 |
echo json_encode($arr, JSON_UNESCAPED_SLASHES); |
Try it!