3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.4.5 - 7.1.0
Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: String offset cast occurred in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: Undefined index: in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: String offset cast occurred in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: Undefined index: in /in/jT6o9 on line 23
Output for 5.4.0 - 5.4.4
Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: String offset cast occured in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: Undefined index: in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: String offset cast occured in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: Undefined index: in /in/jT6o9 on line 23
Output for 5.3.0 - 5.3.29
Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: Undefined index: in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Warning: key() expects parameter 1 to be array, string given in /in/jT6o9 on line 23 Notice: Undefined index: in /in/jT6o9 on line 23
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/jT6o9 on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/jT6o9 on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/jT6o9 on line 21
Process exited with code 255.