WP_REST_Request::get_header_as_array()publicWP 4.4.0

Retrieves header values from the request.

Method of the class: WP_REST_Request{}

No Hooks.

Return

Array|null. List of string values if set, null otherwise.

Usage

$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->get_header_as_array( $key );
$key(string) (required)
Header name, will be canonicalized to lowercase.

Changelog

Since 4.4.0 Introduced.

WP_REST_Request::get_header_as_array() code WP 6.4.3

public function get_header_as_array( $key ) {
	$key = $this->canonicalize_header_name( $key );

	if ( ! isset( $this->headers[ $key ] ) ) {
		return null;
	}

	return $this->headers[ $key ];
}