3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $bookData = []; foreach ([1, 2, 3, 5, 8, 13, 21] as $value) { $book = new stdClass; $book->price = $value; $bookData[] = $book; } $priceFilter = function($minimumValue, $maximumValue) { return function($value) use ($minimumValue, $maximumValue) { return $value->price >= $minimumValue && $value->price < $maximumValue; }; }; var_dump(array_filter( $bookData, $priceFilter(5.00, 15.00) )); var_dump(array_filter( $bookData, $priceFilter(1.00, 10.00) ));
based on 4GvWU
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.2.6
array(3) { [3]=> object(stdClass)#4 (1) { ["price"]=> int(5) } [4]=> object(stdClass)#5 (1) { ["price"]=> int(8) } [5]=> object(stdClass)#6 (1) { ["price"]=> int(13) } } array(5) { [0]=> object(stdClass)#1 (1) { ["price"]=> int(1) } [1]=> object(stdClass)#2 (1) { ["price"]=> int(2) } [2]=> object(stdClass)#3 (1) { ["price"]=> int(3) } [3]=> object(stdClass)#4 (1) { ["price"]=> int(5) } [4]=> object(stdClass)#5 (1) { ["price"]=> int(8) } }