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
Post a Comment