3v4l.org

run code in 300+ PHP versions simultaneously
<?php $certificates = array( $array( 'num' => '111', 'name' => 'cert1' ), $array( 'num' => '222', 'name' => 'cert2' ) ); //получаем массив который содержит 'name' => 'cert2' class ArrayFilter { private $array; private $field; private $value; function __construct($array, $field, $value) { $this->array = $array; $this->field = $field; $this->value = $value; } function dataCorrect() { return $this->array[$this->field] == $this->value; } } $field = 'name'; $value = 'cert1'; $out = array_filter( $certificates, array(new ArrayFilter($certificates, $field, $value), 'dataCorrect') ); print_r($out);
Output for 5.4.0 - 5.4.19
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/boLqI on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_DOUBLE_ARROW in /in/boLqI on line 5
Process exited with code 255.

preferences:
187.05 ms | 1386 KiB | 55 Q