- array_slice: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
<?php
function get_tld() {
$host = explode( ':', 'refer-wordpress-com-staging.go-vip.co' );
$domain_list = explode( '.', $host[0] );
return ( count( $domain_list ) > 1 ) ? implode( '.', array_slice( $domain_list, - 2 ) ) : $host[0];
}
echo get_tld();