src/Traits/Collections.php
public static function doForEach($collection, Closure $iterateFn)
    {
        foreach ($collection as $key => $value) {
            if ($iterateFn($value, $key, $collection) === false) {
                break;
            }
        }
        return true;
    }
public static function doForEach($collection, Closure $iterateFn)
    {
        foreach ($collection as $key => $value) {
            if ($iterateFn($value, $key, $collection) === false) {
                break;
            }
        }
        return true;
    }
public static function doForEach ( $ collection , Closure $ iterateFn ) { foreach ( $ collection as $ key => $ value ) { if ( $ iterateFn ( $ value , $ key , $ collection ) === false ) { break ; } } return true ; }
Iterate over elements of the collection and invokes iterate for each element.

The iterate is invoked with three arguments: (value, index|key, collection).
Iterate functions may exit iteration early by explicitly returning false.

@usage __::doForEach([1, 2, 3], function ($value) { print_r($value) });
>> (Side effect: print 1, 2, 3)

@param array|object $collection The collection to iterate over.
@param \Closure     $iterateFn  The function to call for each value

@return boolean
Iterate over elements of the collection and invokes iterate for each element .