这是我的json编码数据
echo json_encode($something)
从mongodb数据库给我这个
[
{
"_id":{ "$id":"535f6dc8b8082fd3f80dea0f"},
"val":"mukund",
"value":"Lost in the woods"
}
]
我只需要从该数组获取535f6dc8b8082fd3f80dea0f
,mukund
和Lost in the woods
变量$ id,$ name,$ Text
请帮助
答案 0 :(得分:1)
尝试使用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