Iterables
Iterables
is a built-in compile time type alias for
.
From its introduction in PHP 7.1.0 and prior to PHP 8.2.0,
was a built-in pseudo-type that acted as the
aforementioned type alias and can be used as a type declaration.
An iterable type can be used in foreach and with
within a
.
Iterable``array|Traversable``iterablegenerator
Opmerking: > Functions declaring iterable as a return type may also be .
generators**Voorbeeld: Iterable generator return type example **
<?php function gen(): iterable { yield 1; yield 2; yield 3; } foreach(gen() as $value) { echo $value, "\n"; } ?>