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:

  1. www.yahoo.com
  2. 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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -