Here's are some example hostnames:
test.whatever.es.example.com
more.test.pages.fr.example.com
test.website.de.example.com
The domain is always example.com
and doesn't change.
How do I get the subdomain directly next to example.com
and then get everything before that?
For example, I'd like to be able to do something along these lines:
echo "$domain - $sub_domain - $sub_sub_domains";
And get this (depending on which of the examples above is used):
example.com - es - test.whatever
example.com - fr - more.test.pages
example.com - de - test.website
I'm trying to do this in PHP and I've tried a few options, but none of them seem to be working :/