Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get domain name from full URL Example

function fetchLiveDomain($url){
    $parts = parse_url($url);
    $domain = isset($parts['host']) ? $parts['host'] : '';
    if(preg_match('/(?P<domain>[a-z0-9][a-z0-9-]{1,63}.[a-z.]{2,6})$/i', $domain, $regs)){
        return $regs['domain'];
    }
    return FALSE;
}

echo fetchLiveDomain("https://www.pakainfo.com"); // outputs 'pakainfo.com'
echo fetchLiveDomain("http://www.pakainfo.com"); // outputs 'pakainfo.com'
echo fetchLiveDomain("http://mail.pakainfo.co.uk"); // outputs 'pakainfo.co.uk'
Source by www.pakainfo.com #
 
PREVIOUS NEXT
Tagged: #Get #domain #full #URL #Example
ADD COMMENT
Topic
Name
4+8 =