If the value of $myVar($_SERVER["SERVER_NAME"]) is "dot.kr",
I like to get the modified value of $myVar is "dot.kr"

If the value of $myVar is "www.dot.kr",
I like to get the modified value of $myVar is "dot.kr"

If the value of $myVar is "europe.dot.kr",
I like to get the modified value of $myVar is "dot.kr"

If the value of $myVar is "france/europe.dot.kr",
I like to get the modified value of $myVar is "dot.kr"

If the value of $myVar is "site.com",
I like to get the modified value of $myVar is "site.com"

If the value of $myVar is "www.site.com",
I like to get the modified value of $myVar is "site.com"

If the value of $myVar is "france/europe.site.com",
I like to get the modified value of $myVar is "site.com"

How can I modify $myVar for getting my target value(mainDomain) from each dynamic variable value(subDomain+mainDoamin) ?

(I like to get the main(registered) domain from the subDomains and mainDomains.)