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){ 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' ) ); $name = 'vasya2'; //print_r(array_filter($array1, array(new ArrayFilters($array1, 'vasya2'), 'name_is'))); print_r( array_filter( $array1, function($value) use ($name, $ok = '1') { echo $ok; return $value['name'] == $name; } ) );
Output for 5.3.0 - 5.4.19
Parse error: syntax error, unexpected '=', expecting ',' or ')' in /in/K9NAZ on line 45
Process exited with code 255.