<?php
function parseLinkHeader(string $linkHeader): array {
$out = [];
foreach (explode(',', $linkHeader) as $part) {
if (!preg_match('/<([^>]+)>;\s*rel="?([^";]+)"?/', $part, $m)) continue;
$out[$m[2]] = $m[1];
}
return $out;
}
// Example response header from GitHub:
$header = '<https://api.github.com/repos/foo/bar/issues?page=2>; rel="next", '
. '<https://api.github.com/repos/foo/bar/issues?page=10>; rel="last"';
$rels = parseLinkHeader($header);
echo $rels['next']; // https://api.github.com/.../issues?page=2
Create a free account and build your private vault. Share publicly whenever you want.