tags:

views:

22

answers:

2

i have a lot of urls ending with .com,.com.eu,.fr,.hk etc ..i need to filter the domains only end with .com and .fr ... using php....

+1  A: 

You can use preg_match on each URL

preg_match('/(.*)\.(com|fr)$/', $domain, $tokens)

$tokens[1] will contain the domain name (and $tokens[2] will contain .fr or .com)

nico
ya it worked for me thanks...
Raja
A: 

Split the string with "." character and choose the last element like

if(end(explode(".",$DOMAIN)) == "com")
        DO_XYZ
Shubham