PHP String Match For Domain Name – String Function

 
    <?
function simple_dot_com ($url) {
  return(ereg('^www\.[a-z]+\.com$', $url));
}$urls_to_test =
   array('www.ibm.com', 'www.java.sun.com',
         'www.zend.com', 'java.sun.com',
         'www.java.sun.com', 'www.php.net',
         'www.IBM.com',
         'www.Web addresses can\'t have spaces.com');while($test = array_pop($urls_to_test)){
  if (simple_dot_com($test))
    print("\"$test\" is a simple dot-com<br />");
  else
    print("\"$test\" is NOT a simple dot-com<br />");
 
}?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.