3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php DEFINE('FILTER_OPTIONS', ['odd', 'even']); /* Array filtering * * @param $array array the input array * @param $filterParameter string 'odd' or 'even' * * @return array|bool it returns the filtered array. In any other case it should return false. */ function filterArray($array, $filterParameter) { if (! is_array($array) || ! in_array($filterParameter, FILTER_OPTIONS)) { return false; } return array_filter($array, function ($e) use ($filterParameter) { return $filterParameter === 'odd' ? $e % 2 === 1 : $e % 2 === 0; }); } $array = [1,2,3,4,5,6,7]; var_dump(filterArray(1, 'odd'));
based on YZnaF
Output for 7.0.0 - 7.3.0beta1
bool(false)
Output for 5.6.0 - 5.6.30, hhvm-3.15.4
Warning: Constants may only evaluate to scalar values in /in/Q2UK6 on line 3 bool(false)