How to convert php string with backslashes to json array -


i want produce json array using php

{"to": "/topics/foo-bar"} 

but if use code :

$topic = "/topics/foo-bar";     $g_topic= array(                 'to' => $topic             );     echo json_encode($g_topic ); 

it returning

{"to": "/topics/foo-bar"}

i have tried stripslashes(), addslashes(), none of methods worked

it right there in the manual json_encode() function:

echo json_encode($g_topic, json_unescaped_slashes); 

will yield:

{"to": "/topics/foo-bar"} 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -