Capture data between these tags

I have an array which contains the following


<a href="http://linktoasite" rel="bookmark" title="Permanent Link to linktoasite">something random</a> <img style="border:none;padding:0;position:relative;top:4px" src="online.png">

how would i strip out just the first link and ignore the rest so it would echo

http://linktoasite

Solved


$matches = null;
$returnValue = preg_match_all('#<a href="(.*?)" rel=#is', <a href="http://linktoasite" rel="bookmark" title="Permanent Link to linktoasite">something random</a> <img style="border:none;padding:0;position:relative;top:4px" src="online.png">
)', $matches, PREG_PATTERN_ORDER);