Table of Contents

function iterate()

Prototype

void|array iterate(array|Traversable $list, bool $collect = false)

Example implementation

function iterate($list, $collect = false)
{
    if ($collect) $result = array();
    foreach ($list as $element) {
        if ($collect) $result[] = $element;
    }
    if ($collect) return $result;
}