src/Support/Arr.php
/**
	 * Return the first element in an array passing a given truth test. If no truth test is provided, returns the
	 * very first element in the array.
	 *
	 * @param array $array
	 * @param callable|null $callback
	 * @param mixed $default
	 * @return mixed
	 */
Return the first element in an array passing a given truth test. If no truth test is provided, returns the
very first element in the array.

@param array $array
@param callable|null $callback
@param mixed $default
@return mixed
Return the first element in an array passing a given truth test . If no truth test is provided returns the very first element in the array . @param array $array @param callable|null $callback @param mixed $default @return mixed
public static function first($array, $callback = null, $default = null) {
		if (is_null($callback)) {
			if (empty($array)) {
				return $default;
			}
			foreach ($array as $item) {
				return $item;
			}
		}
		foreach ($array as $key => $value) {
			if (call_user_func($callback, $value, $key)) {
				return $value;
			}
		}
		return $default;
	}
public static function first ( $ array , $ callback = null , $ default = null ) { if ( is_null ( $ callback ) ) { if ( empty ( $ array ) ) { return $ default ; } foreach ( $ array as $ item ) { return $ item ; } } foreach ( $ array as $ key => $ value ) { if ( call_user_func ( $ callback , $ value , $ key ) ) { return $ value ; } } return $ default ; }
Return the first element in an array passing a given truth test.
Return the first element in an array passing a given truth test .