Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to Extract Domain Name from URL using PHP
  2. <a href='http://google.com.site.com'>google.com</a><br /><a href='http://youtube.com.site.com'>youtube.com</a><br />
  3.        
  4. preg_match_all ("/a[s]+[^>]*?href[s]?=[s"']+".
  5.                     "(.*?)["']+.*?>"."([^<]+|.*?)?</a>/",
  6.                     $var, &$matches);
  7.  
  8.     $matches = $matches[1];
  9.     $list = array();
  10. sort($matches);
  11.        
  12. >(.*?)</a>
  13.        
  14. <a href=['|"](.*?)?['|"]>
  15.        
  16. $s = '<a href='http://google.com.site.com'>google.com</a><br /><a href='http://youtube.com.site.com'>youtube.com</a><br /><a href='http://youtube.com.site.com'>extratube.com</a>';
  17.  
  18. $pattern = '#>(.*?)</a>(<br />)*#';
  19. preg_match_all($pattern, $s, $result);
  20. var_dump($result);
  21.        
  22. <a[^>]*>(.*?)</a>