Skip to content
Devin Smith edited this page Feb 3, 2016 · 10 revisions

Looper provides an interface similar to Iterator with some Resource specific features.


Methods

each

Looper allows the use of either $object->each() or foreach ($object) interchangeably.

foreach ($loop as $item) {
	//item
}

or

$loop->each(function() {
	// $this
});

filter

$loop = new \Tipsy\Looper([ (object)['a' => 1], (object)['a' => 2], (object)['a' => 3] ]); $val = 0; $loop->each(function() use (&$val) { $val += $this->a; }); echo $val; // outputs 6