How to get domain from path ?

    Use the following code
    <?php
    $domain
    = fetch_domain_name('http://www.facebook.com');
    print
    $domain; //it will output "facebook"
    function fetch_domain_name($path){
       
    $check = preg_match("/(.*:\/\/)\w{0,}(.*)\.(.*)/", $path, $output);
       
    $output[2] = str_replace(".","",$output[2]);
        return
    $output[2];
    }
    ?>
    4
    Average: 4 (1 vote)