3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( json_decode('{"name": "foo1", "other": "test"}'), json_decode('{"name": "foo2", "other": "test"}'), json_decode('{"name": "foo3", "other": "test"}'), ); $name = 'foo2'; echo "INPUT\n", str_repeat('=', 20), "\n"; var_dump($input); echo "\n"; echo "RESULT\n", str_repeat('=', 20), "\n"; var_dump( $result = array_filter($input, function($o) use ($name) { return $o->name == $name; }) ); echo "usage\n", str_repeat('=', 20), "\n"; $match = array_pop($result); var_dump($match->other);
Output for git.master, git.master_jit, rfc.property-hooks
INPUT ==================== array(3) { [0]=> object(stdClass)#1 (2) { ["name"]=> string(4) "foo1" ["other"]=> string(4) "test" } [1]=> object(stdClass)#2 (2) { ["name"]=> string(4) "foo2" ["other"]=> string(4) "test" } [2]=> object(stdClass)#3 (2) { ["name"]=> string(4) "foo3" ["other"]=> string(4) "test" } } RESULT ==================== array(1) { [1]=> object(stdClass)#2 (2) { ["name"]=> string(4) "foo2" ["other"]=> string(4) "test" } } usage ==================== string(4) "test"

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:
52.16 ms | 402 KiB | 8 Q