now i waned to use it as array so how can i use it as array
Hi Omkar,
Assuming you’re using MongoDB PHP Library, the find() method returns a MongoDB\Driver\Cursor object which you could iterate to access all matched documents. For example:
$collection = (new MongoDB\Client)->databaseName->collectionName;
$cursor = $collection->find(['field' => 'value_to_search']);
foreach ($cursor as $document) {
var_dump($document);
}
Depending on what you’re trying to achieve, you could also store the result into a PHP array if you prefer, an example:
$array_stack = array();
$cursor = $collection->find(['field' => 'value_to_search']);
foreach ($cursor as $document) {
// push to our array variable.
array_push($array_stack, $document);
}
print_r($array_stack);
I would recommend to check out MongoDB PHP Library CRUD tutorial. There are good examples and guides to help you be familiar with MongoDB operations via PHP. See also MongoDB for the PHP mind part 1.
If you have further questions, please provide:
Regards,
Wan.