Pull the href attribute out of an html link element.
function _openid_link_href($rel, $html) {
$html_dom = new DOMDocument();
if (@$html_dom
->loadHTML($html)) {
$html_element = simplexml_import_dom($html_dom);
if (isset($html_element->head->link)) {
foreach ($html_element->head->link as $link) {
// The rel attribute contains a space-separated list of case-insensitive
// link types.
if (preg_match('@(?:\\s|^)' . preg_quote($rel, '@') . '(?:\\s|$)@i', $link['rel'])) {
return trim($link['href']);
}
}
}
}
return FALSE;
}