This example uses mongo_has_next and mongo_next to
iterate through query results and storing them in
an array.
<?php
$conn = mongo_connect("localhost", true);
if (!$conn) {
die("Could not connect.");
}
$cursor = mongo_query($conn, "foo.bar", array(), 0, 0, null, null, null);
$results = array();
while (mongo_has_next($cursor)) {
$results[] = mongo_next($cursor);
}
?>