3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); function test(&$item, $key) { if($item == 'orange') return false; return true; } array_filter($fruits, 'test'); var_dump($fruits);
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function test(), 1 passed and exactly 2 expected in /in/KSWPO:5 Stack trace: #0 [internal function]: test('lemon') #1 /in/KSWPO(14): array_filter(Array, 'test') #2 {main} thrown in /in/KSWPO on line 5
Process exited with code 255.
Output for 4.3.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 2 for test() in /in/KSWPO on line 5 Warning: Missing argument 2 for test() in /in/KSWPO on line 5 Warning: Missing argument 2 for test() in /in/KSWPO on line 5 Warning: Missing argument 2 for test() in /in/KSWPO on line 5 array(4) { ["d"]=> string(5) "lemon" ["a"]=> string(6) "orange" ["b"]=> string(6) "banana" ["c"]=> string(5) "apple" }
Output for hhvm-3.10.0 - 3.12.0
Warning: test() expects exactly 2 parameters, 1 given in /in/KSWPO on line 7 Warning: test() expects exactly 2 parameters, 1 given in /in/KSWPO on line 7 Warning: test() expects exactly 2 parameters, 1 given in /in/KSWPO on line 7 Warning: test() expects exactly 2 parameters, 1 given in /in/KSWPO on line 7 array(4) { ["d"]=> string(5) "lemon" ["a"]=> string(6) "orange" ["b"]=> string(6) "banana" ["c"]=> string(5) "apple" }