php - How to fetch all the urls which are not linked using regex -
i need fetch urls given string not linked(url without anchor tag).
i know regex (http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?
fetch urls given string.
input:
<div class='test'> <p>heading</p> <a href='http://www.google.com'>google</a> www.yahoo.com http://www.rediff.com <a href='http://www.overflow.com'>www.overflow.com</a> </div>
output:
- www.yahoo.com
- http://www.rediff.com
kindly advise.
use library dom tree html, , links. example can use simplehtml http://simplehtmldom.sourceforge.net/
// create dom url or file $html = file_get_html('http://www.google.com/'); // find links foreach($html->find('a') $element) { echo $element->href . '<br>'; }
Comments
Post a Comment