wp_remote_retrieve_header( array|WP_Error $response, string $header ): array|string

Retrieves a single header by name from the raw response.

Parameters

$responsearray|WP_Errorrequired
HTTP response.
$headerstringrequired
Header name to retrieve value from.

Return

array|string The header(s) value(s). Array if multiple headers with the same name are retrieved.
Empty string if incorrect parameter given, or if the header doesn’t exist.

Source

function wp_remote_retrieve_header( $response, $header ) {	if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {	return '';	}	if ( isset( $response['headers'][ $header ] ) ) {	return $response['headers'][ $header ];	}	return ''; } 

Changelog

VersionDescription
2.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.