I find the DOMDocument() class handles this elegantly. This snippet of code should help you (put the entire html tag including the div
wrapper in the $tag
variable):
$d = new DOMDocument();
$d->loadHTML($tag);
$a = $d->getElementByTagName('a');
$href = $a->item(0)->getAttribute('href');
The $href
variable will have the attribute value of href.