Anemone::getIterator()

The external iterator receiver.

Table of Contents
  1. Description
  2. Example

Description

Anemone::getIterator(): Traversable;

This method is a requirement to be able to implement the IteratorAggregate interface and aims to make the object iterable directly. You won’t use this method directly, iteration control structures such as for, foreach and while will call this method automatically.

Example

$anemone = new Anemone([1, 2, 3, 4, 5]);

// Using `for` loop
for ($i = 0, $j = count($anemone); $i < $j; ++$i) {
    echo $i . ': ' . $anemone[$i] . '<br>';
}

// Using `foreach` loop
foreach ($anemone as $k => $v) {
    echo $k . ': ' . $v . '<br>';
}

// Using `while` loop
while ($v = $anemone->first(true)) {
    echo $v . '<br>';
}

Anemone::any()

Checks if at least one item in the data passes the test.

Anemone::getIterator()

The external iterator receiver.

Anemone::is()

Filters the data so that only items that pass the test are left.

Anemone::not()

Filters the data so that only items that do not pass the test are left.

Anemone::pluck()

Returns a new data set contains values from the key on every item.