This is my json encoded data
echo json_encode($something)
gave me this from mongodb database
[
{
"_id":{ "$id":"535f6dc8b8082fd3f80dea0f"},
"val":"mukund",
"value":"Lost in the woods"
}
]
i need to get 535f6dc8b8082fd3f80dea0f
, mukund
and Lost in the woods
only from that array to variables $id, $name, $Text
please help
try with json_decode()
$j = '[{"_id":{"$id":"535f6dc8b8082fd3f80dea0f"},"val":"mukund","value":"Lost in the woods"}]';
$r = json_decode($j);
echo (string)$r[0]->_id->{'$id'}; //535f6dc8b8082fd3f80dea0f
echo $r[0]->val; //mukund
echo $r[0]->value; //Lost in the woods