3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class NumericComparisonFilter { private $reference; function __construct($reference) { $this->reference = $reference; } function isLower($num) { return $num < $this->reference; } function isGreater($num) { return $num > $this->reference; } function isEqual($num) { return $num == $this->reference; } } $arr = array(7, 8, 9, 10, 11, 12, 13); $matches = array_filter($arr, array(new NumericComparisonFilter(10), 'isLower')); print_r($matches); $matches = array_filter($arr, array(new NumericComparisonFilter(10), 'isGreater')); print_r($matches); $matches = array_filter($arr, array(new NumericComparisonFilter(10), 'isEqual')); print_r($matches);
Output for 5.0.0 - 7.1.0
Array ( [0] => 7 [1] => 8 [2] => 9 ) Array ( [4] => 11 [5] => 12 [6] => 13 ) Array ( [3] => 10 )
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/XlfSn on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/XlfSn on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/XlfSn on line 4
Process exited with code 255.