I have a query string with URL-encoded symbols:
$wm_string = "LMI_MODE=1&LMI_PAYMENT_DESC=%CF%EE%E6%E5%F0%F2%E2%EE%E2%E0%ED%E8%E5+Plan+Z";
I need to convert it into JSON with PHP, but json_encode returns an empty string.
Here is my code in PHP:
parse_str($wm_string, $_REQUEST);
var_dump($_REQUEST);
echo "JSON:".json_encode($_REQUEST);
Here is the result:
array(1) { ["LMI_MODE"]=> string(46) "1?LMI_PAYMENT_DESC=Пожертвование Plan Z Online" } JSON:
What should I do?
UPDATE:
The expected result is:
{
"LMI_MODE":1,
"LMI_PAYMENT_DESC":"Пожертвование Plan Z Online"
}
UPDATE2:
The encoding is windows-1251, while json_encode seems to be expecting UTF-8. Is there a way to tell json_encode which encoding it should use while parsing?