3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ValueFilter { private $minimumValue; private $maximumValue; public function __construct($min, $max) { $this->minimumValue = $min; $this->maximumValue = $max; } public function __invoke($value) { return $value >= $this->minimumValue && $value < $this->maximumValue; } } $values = [1, 2, 3, 5, 8, 13, 21]; print_r(array_filter($values, new ValueFilter(5, 20))); print_r(array_filter($values, new ValueFilter(2, 6)));

preferences:
50.77 ms | 402 KiB | 5 Q