how to store json output into seperate PHP variables?
{"msg":"success","msg_text":{"9912345678":"N"}}
how to store json output into seperate PHP variables?
{"msg":"success","msg_text":{"9912345678":"N"}}
Agree with @jkon, please use the json_decode() to decode the json format into array. Then from the array, manually assign them into another variable(if it really needed).
You want 'separate' variables?
The json you supply will give the following with json_decode when 2nd param set to true:
['msg' => 'success', 'msg_text' => ['9912345678' => 'N']]
If you need to extract to separate variables you can do it manually:
$msg = $array['msg'];
$msg_key = key($array['msg_text']);
$msg_value = $array['msg_text'][$msg_key];
Alternatively use a loop to get key=>value.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.
You're trying to visit a URL that doesn't currently exist on the web. Most likely, a member posted a link a long time ago to a web page that has since been removed. It's also possible that there was a typo when posting the URL. We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.