PHPverse 2025

Voting

: six minus zero?
(Example: nine)

The Note You're Voting On

cg at papoo dot de
3 years ago
Since php-mongodb version 1.9.0 Cursor implements Iterator, but if you need to support older versions too, you can conditionally wrap the cursor with IteratorIterator:

<?php
$iterator
= $collection->find();

if (!(
$iterator implements Iterator)) {
$iterator = new \IteratorIterator($iterator);
}
?>

<< Back to user notes page

To Top