String match for domain name
<?
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>");
}
?>
Related examples in the same category