3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { var $name; var $age; function __construct($name, $age) { $this->name = $name; $this->age = $age; } } $a = new ArrayIterator([ new Person("Christoph", 15), new Person("John", 42), new Person("Foobar", 25) ]); function first_match(\Iterator $iterator, callable $callback) { foreach ($iterator as $key => $value) { if ($callback($value, $key)) { yield $key => $value; break; } } } $firstOver18 = function($person) { return $person->age >= 18; }; foreach (first_match($a, $firstOver18) as $p) { var_dump($p); }
Output for git.master, git.master_jit, rfc.property-hooks
object(Person)#3 (2) { ["name"]=> string(4) "John" ["age"]=> int(42) }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.63 ms | 401 KiB | 8 Q