I am trying to retrieve one element from a mongo collection, the one with the greatest _id field. I know this can be done by querying:
db.collection.find().s
$maxId=""; $Cursor =$collection->find(); foreach($cursor as $document) { $maxid =max($arr=(array($document['id']))); } print_r($maxid+1);