3v4l.org

run code in 300+ PHP versions simultaneously
<?php $table = array( array( "name" => "1", "age" => 10, "answer" => "One" ), array( "name" => "2", "age" => 20, "answer" => "Two" ) ); $input = array( "name" => "2", "age" => 20 ); $isEntryMatches = array_reduce($table, function($result, $entry) use ($input) { $isValuesMatches = array_reduce($entry, function($result, $value) use ($input) { return $result && $value[key($value)] == $input[key($value)]; }, true); }, true); print $isEntryMatches;
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: key(): Argument #1 ($array) must be of type array, string given in /in/jT6o9:23 Stack trace: #0 /in/jT6o9(23): key('1') #1 [internal function]: {closure}(true, '1') #2 /in/jT6o9(22): array_reduce(Array, Object(Closure), true) #3 [internal function]: {closure}(true, Array) #4 /in/jT6o9(21): array_reduce(Array, Object(Closure), true) #5 {main} thrown in /in/jT6o9 on line 23
Process exited with code 255.

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