我遇到以下代码的问题。
if ($cursor->count() > 0)
{
$test = array();
// iterate through the results
while( $cursor->hasNext() ) {
$test[] = ($cursor->getNext());
}
//print_r($test);
foreach($test as $d) {
print_r($d);
$current_name = $d[0]['personal']['name'];
}
}
但是当我在我的mongodb中时,我有
array("personal"=>array("name"=>"rusty"));
答案 0 :(得分:1)
修改为:
foreach($test as $d)
{
print_r($d);
$current_name = $d['personal']['name'];
}