- strpos: documentation ( source)
- strrev: documentation ( source)
<?php
$current_url_host = 'sub.example.com';
$main_url_host = 'example.com';
$current_url_host_rev = strrev( $current_url_host );
$main_url_host_rev = strrev( $main_url_host );
if ( strpos( $current_url_host_rev, $main_url_host_rev ) === 0 ) {
echo 'z';
}
$current_url_sub_domains = strrev( $current_url_host_rev );
echo $main_url_host_rev;