This format displays the documents returned from the query as stdClass Objects. For display purposes, it's fine, but if certain computations need to be performed using the returned documents and their corresponding fields, use this:
------------------------------------Code Snippet-----------------------------------
$connection = new MongoDBDriverManager("mongodb://localhost:27017");
$filter = ["name"=>"insert_desired_name_here"];
/* the following condition, and others similar to it, work as well
$filter = ["age"=>["$gt"=>"18"]]; /*/
$options = []; /* put desired options here, should you need any */
$query = new MongoDBDriverQuery($filter,$options);
$documents = $connection->executeQuery('trial.trial' /*dbname.collection_name*/,$query);
foreach($documents as $document){
$document = json_decode(json_encode($document),true);
echo $document[name];
}
--------------------------------------------------------------------------------------
The first executable statement inside the foreach encodes the returned stdClass object to a json object, and the same is immediately decoded to an associative array, which can then be used as and when needed