title: mongodb and php how to output results using geoNear
body: <p>I am trying to output results using the geoNear command using PHP but what I keep getting back is one document that I can retrieve using print_r.</p>
  
  <p>This is my example the search 1 works fine but search 2 doesn't do anything.</p>
  
  <pre><code>    &lt;?php
      $mongo = new Mongo();
  
      $collection = $mongo-&gt;selectDB('users')-&gt;selectCollection('user');
  
      $lng = -2.28;
      $lat = 53.46;
      $lnglat = array($lng, $lat);
      $query = array('loc' =&gt; array('$near' =&gt; $lnglat));
  
      //search 1
      $cursor = $collection-&gt;find($query)-&gt;limit(10);
  
  
      while($cursor-&gt;hasNext()){
          $user = $cursor-&gt;getNext();
          echo $user['username'] . "&lt;br /&gt;";
      };
  
      //search 2
      $cursor2 = $mongo-&gt;selectDB('users')-&gt;command(array(
                      'geoNear' =&gt; 'user',
                      'near' =&gt; $lnglat,
                      'spherical' =&gt; true,
                      'num' =&gt; 10 )); 
  
      while($cursor2-&gt;hasNext()){
          $user = $cursor2-&gt;getNext();
          echo $user['username'] . "&lt;br /&gt;";
      };
      ?&gt;
  </code></pre>