3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ArrayFilters { private $array = array(); private $name; public function __construct($array, $name){ $this->array = $array; $this->name = $name; } public function name_is($arr){ print_r($this->name ); return $arr['name'] == $this->name; } } $array1 = array( "a"=>array( 'name' => 'vasya' ,'second_name' => 'Vasilev' ), "b"=>array( 'name' => 'vasya2' ,'second_name' => 'Vasilev2' ), "c"=>array( 'name' => 'vasya3' ,'second_name' => 'Vasilev3' ), "d"=>array( 'name' => 'vasya4' ,'second_name' => 'Vasilev4' ), "e"=>array( 'name' => 'vasya5' ,'second_name' => 'Vasilev5' ) ); print_r(array_filter($array1, array(new ArrayFilters($array1, 'vasya2'), 'name_is')));
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
vasya2vasya2vasya2vasya2vasya2Array ( [b] => Array ( [name] => vasya2 [second_name] => Vasilev2 ) )
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/iGhcp on line 3
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/iGhcp on line 3
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/iGhcp on line 3
Process exited with code 255.