fer0an Posted July 31, 2010 Share Posted July 31, 2010 hello I've some code same as below: <div class="center"><a href="http://hotfile.com/dl/58656550/d2428c9/INV.1908.pdf.html" target="_blank" rel="nofollow">Hotfile</a><br/> <br/> <a href="http://sharingmatrix.com/file/15447295/INV.1908.pdf" target="_blank" rel="nofollow">Sharingmatrix</a></div> </div> now I wan extract URL of links from it. sometimes this codes have 1 or 2 or 3 url. can anyone help me? Link to comment https://forums.phpfreaks.com/topic/209431-find-url-in-code/ Share on other sites More sharing options...
cags Posted July 31, 2010 Share Posted July 31, 2010 The correct way would be to not use Regex but to use some form of DOM. A really simple regex that would work most of the time but is the wrong way to do it... preg_match_all('#<a[^>]* href=("|\')([^\1]+)\1[^>]*>#U', $input, $out); print_r($out); Link to comment https://forums.phpfreaks.com/topic/209431-find-url-in-code/#findComment-1093538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.