PHP Tutorial

Get domain extension

<?php
        // input 
         $domain = "www.example.com";
         // get extension
         $extension = substr($domain,-strpos(strrev($domain),'.')); // the last occurence in the string
         print("The domain extension is: $extension \n");
?>