3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a=array( array('id'=>1), array('id'=>2), array('id'=>3), array('id'=>4), ); var_dump($a); $finalResultID=3; $x= array_filter($a, function($el) use($finalResultID) { return $el['id'] == $finalResultID; }); reset($x); var_dump($x);
based on sZbnQ
Output for 5.3.0 - 7.2.6
array(4) { [0]=> array(1) { ["id"]=> int(1) } [1]=> array(1) { ["id"]=> int(2) } [2]=> array(1) { ["id"]=> int(3) } [3]=> array(1) { ["id"]=> int(4) } } array(1) { [2]=> array(1) { ["id"]=> int(3) } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/KHiLg on line 12
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/KHiLg on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/KHiLg on line 12
Process exited with code 255.