1

I am having an issue with the following code below.

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'];
           }
        }

but when I in my mongodb I have

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 に答える