3v4l.org

run code in 300+ PHP versions simultaneously
<?php $before = [ ['type' => 'foo'], ['type' => 'only-first-of-this'], ['type' => 'bar'], ['type' => 'only-first-of-this'], ['type' => 'baz'], ]; $found = 0; $after = array_filter( $before, static fn ($item) => $item['type'] !== 'only-first-of-this' || $found++ === 0, ); var_dump($before, $after); $found = 0; $after2 = array_filter( $before, static function ($item) use (&$found) { return $item['type'] !== 'only-first-of-this' || $found++ === 0; }, ); var_dump($after2);
Output for git.master_jit, git.master, rfc.property-hooks
array(5) { [0]=> array(1) { ["type"]=> string(3) "foo" } [1]=> array(1) { ["type"]=> string(18) "only-first-of-this" } [2]=> array(1) { ["type"]=> string(3) "bar" } [3]=> array(1) { ["type"]=> string(18) "only-first-of-this" } [4]=> array(1) { ["type"]=> string(3) "baz" } } array(5) { [0]=> array(1) { ["type"]=> string(3) "foo" } [1]=> array(1) { ["type"]=> string(18) "only-first-of-this" } [2]=> array(1) { ["type"]=> string(3) "bar" } [3]=> array(1) { ["type"]=> string(18) "only-first-of-this" } [4]=> array(1) { ["type"]=> string(3) "baz" } } array(4) { [0]=> array(1) { ["type"]=> string(3) "foo" } [1]=> array(1) { ["type"]=> string(18) "only-first-of-this" } [2]=> array(1) { ["type"]=> string(3) "bar" } [4]=> array(1) { ["type"]=> string(3) "baz" } }

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:
26.01 ms | 408 KiB | 5 Q