$links= 'Test Link <a href="http://www.google.co.th" class="something">Google Thailand</a> Test <a href="http://www.google.com" class="red">Google Global</a> Test <a href="http://www.test.com/index.php" id="test" class="something">Test dot com index page</a> Test <a href="http://sub.test.com/" class="something">Sub domain of test dot com</a> Test <a href="http://www.test.com/index.php?id=555" class="something">Test dot com with query string</a>';
$results = array();
preg_match_all("/<a href=\"([^\"]+)\"[^>]*>([^<]*)<\/a>/i",$links,$results);
echo print_r($results[1]);
echo "<br />";
echo print_r($results[2]);