Forum Moderators: coopster
I have an array that contains different domain names:
$domain_list=array("domain.edu","website.edu","site.edu","school.ac.uk");
I have a variable $url that I need to treat differently depending on if the domain of $url is in the $domain_list.
I calculate the domain of $url using:
$domain=strtolower(parse_url($url,PHP_URL_HOST));
if(substr($domain,0,4)=="www.") $domain=substr($domain,4);
And detect if the $domain is in the $domain_list using:
if(in_array($domain,$follow_links)){...}
else{...}
That works great, except when the $url links to a subdomain, like:
[mail.domain.edu...]
[students.website.edu...]
[art.site.edu...]
Is there any way to make the script match if the $url is in the array, and not match links to sites like:
[notdomain.edu...]
[mysite.edu...]
[notschool.ac.uk...]
[other.ac.uk...]
[website.edu.junksite.com...]
Thanks