1

In PHP 7.1 a new iterable pseudo-type was introduced.

Is there a straightforward way to transform a generic iterable into an Iterator? Or should I use something like

if (is_array($iterable)) {
    return new \ArrayIterator($iterable);
}

return new \IteratorIterator($iterable);
marcosh
  • 8,780
  • 5
  • 44
  • 74

0 Answers0