这是我的脚本
$terms = ['username' => $uri];
$user = $collection->findOne($terms);
结果
array (size=4)
'_id' =>
object(MongoId)[29]
public '$id' => string '4ff6e96bb0b4599016000006' (length=24)
'username' => string 'me' (length=10)
'name' => string 'Yes, It's me!' (length=16)
获取名称
$name = $user['name'];
但是,我怎样才能得到$user['_id']
?
我尝试$user['_id']
不工作
请帮忙。谢谢
更新
问题解决了$user['_id']->{'$id'}