3v4l.org

run code in 300+ PHP versions simultaneously
<?php $domains = explode(".",str_replace("example.com","","test.example.com")); print "Test: " . $domains[0] . "<br>"; $target = array_pop($domains); print "Target: " . $target . "<br>";

preferences:
39.06 ms | 402 KiB | 5 Q