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"}'), ); 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 = $result[0]; 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 ==================== Warning: Undefined variable $name in /in/Wh6D1 on line 15 array(0) { } usage ==================== Warning: Undefined array key 0 in /in/Wh6D1 on line 20 Warning: Attempt to read property "other" on null in /in/Wh6D1 on line 21 NULL

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