here is the example
> db.test.insert({ name: \'test\', values: [ { check: true }, { check: false } ] }) > db.find({ values.check: true })[0]
$fetchcode = "Fetch an array from the mongo db" foreach ($fetchcode as $mainkey => $mainVariable) { foreach($mainVariable as $key2 => $doc2) { if($key2 == "check"){ if($doc2 == "true") { //Your Function Here } } } }
You can try this