3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Behaves like a PHP array (unstructured) */ class Bag { private $_data; public function __construct(array $data) { $this->data = $data; } public function some(Closure $fn) { return new Bag(array_reduce($this->_data, function ($carry, $x) { return $fn($x) || $carry; }, false)); } public function every(Closure $fn) { return new Bag(array_reduce($this->_data, function ($carry, $x) { return $fn($x) && $carry; }, true)); } public function reduce(Closure $fn) { return new Bag(array_reduce($this->_data, $fn)); } public function map(Closure $fn) { return new Bag(array_map($fn, $this->_data)); } }
Output for git.master, git.master_jit, rfc.property-hooks

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:
46.33 ms | 401 KiB | 8 Q