title: How can i get the object id from loop in mongodb
body: <p>So I want to get the object id from the mongodb using foreach loop.How can I achieve that?</p>
  <pre><code>$cursor2 = $videoCollection-&gt;find(['$text' =&gt; ['$search' =&gt; 'C:/Users/']]);
  
  $cursorArray = json_decode(json_encode($cursor2-&gt;toArray(),true));
  
   foreach ($cursorArray as $key=&gt;$document) {
     print_r($document-&gt;_id);
  }
  </code></pre>
  <p>How can I get the Object Id from this?</p>
  <pre><code> [_id] =&gt; stdClass Object
          (
              [$oid] =&gt; 6246c1c3b5ad6657936980b3
          )
  </code></pre>