1

我对下面的以下代码有疑问。

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"));
4

1 回答 1

1

修改为:

 foreach($test as $d) 
 {
            print_r($d);    
            $current_name = $d['personal']['name'];
 }
于 2012-07-26T10:10:05.373 回答