3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $current_url_host = 'sub.miao.example.com'; $main_url_host = 'example.com'; $current_url_host_rev = strrev( $current_url_host ); $main_url_host_rev = strrev( $main_url_host ); $current_url_sub_domains_rev = ''; if ( strpos( $current_url_host_rev, $main_url_host_rev ) === 0 ) { $current_url_sub_domains_rev = trim( substr( $current_url_host_rev, strlen($main_url_host_rev) ), '.'); } echo strrev($current_url_sub_domains_rev);
Output for 5.6.30, hhvm-3.15.4 - 3.22.0, 7.0.0 - 7.3.0beta2
sub.miao