HTTP2::parseLinks
Synopsis
array HTTP2::parseLinks (
array|string $lines
)
Description
Parses RFC 5988 ("Web Linking") HTTP link headers and splits each of the links up into an array you can then use further.
Example
Usage example
<?php
require_once 'HTTP2.php';
//Link headers that we got from somewhere, e.g.
// HTTP_Request2_Response::getHeader('link')
$link = '<http://pear.php.net/webmention.php>; rel="webmention"';
$http = new HTTP2();
$links = $http->parseLinks($link);
var_dump($links);
?>
The script produces this output:
array(1) { [0] => array(2) { '_uri' => string(34) "http://pear.php.net/webmention.php" 'rel' => array(1) { [0] => string(10) "webmention" } } }
Note that a single link header may contain multiple links. For that reason, the method returns an array of link arrays.
Parameter
-
array|string $lines
- A singleLink:
header value, or an array of multipleLink:
header values, without theLink:
.
Return value
array
- Array of arrays.
Each array describes a link.
The URI is the key _uri
,
all parameters have their names as keys.
The parameters title*
,
rel
and rev
are multi-valued
and thus have an array as their value.
Note
This function can not be called statically.