3v4l.org

run code in 300+ PHP versions simultaneously
<?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'));
Output for git.master, git.master_jit, rfc.property-hooks
bool(false)

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