Issue
I'm trying to remove <p>
and </p>
from my JSON rest API output. I did the below but the output it gives me has double slashes like \\r\\n\\r\\n
. So how do I change the double slashes to single?
Here's my code
//Remove <p> HTML element and replace with line breaks
$return = str_replace('<p>', '', $return);
$return = str_replace('</p>', '\r\n\r\n', $return);
//Output the data in JSON format without escaping the URL slashes
wp_send_json($return, 200, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
Or can the above me more efficient if I use preg_replace?
Solution
all is okay you Just need to use json_deocde in front side or where you want to print the result
Answered By - Salman ansari Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.