You need to get a domain from the url
form http://test.google.com/ (you need to get google.ru) while this option is also possible that will be http://google.com/ (you need to get google.ru) or http: //test.www.google.com/ (you need to get google.com) and even this http://test.privet.www.google.com.com/ (you need to get google.com.com). And in general, not necessarily google domain will be, and maybe yandex and vasya, and generally whatever.
Developments:
parse_url($url, PHP_URL_HOST);
In general, I am talking about the fact that I need to get a main domain name with a domain zone. Domain zones are of the first level and the second: .ru and .ru.com, .com and .com.am, and so on.
That is, so let's say, there must be something like [.*\\.]{0,}(A-Za-z-Π-Π―-Π°-Ρ][\\.]{1,2})
, where that in brackets, should parsitsya. Those. the information that is before the last one or two points should be parsed, as well as the fact that after this information there is a domain zone, but before if there were points before, the information in front of them is not parsed.