function test_first() { $data = array('dev1' => 'Tonya', 'dev2' => 'Julie'); $this->assertEquals('Julie', Arr::first($data, function ($key, $value) { return $value == 'Julie'; })); $this->assertEquals('Julie', wpdevsclub_array_first($data, function ($key, $value) { return $value == 'Julie'; })); }
/** * Return the first element in an array passing a given truth test. * * @param array $array * @param \Closure $callback * @param mixed $default * @return mixed */ function wpdevsclub_array_first($array, $callback, $default = null) { return Arr::first($array, $callback, $default); }