3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PriceFilter { 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 PriceFilter(5, 20))); print_r(array_filter($values, new PriceFilter(2, 6)));

preferences:
29.89 ms | 402 KiB | 5 Q