• I found this:

    $input = 'www.google.co.uk/';
    
    // in case scheme relative URI is passed, e.g., //www.google.com/
    $input = trim($input, '/');
    
    // If scheme not included, prepend it
    if (!preg_match('#^http(s)?://#', $input)) {
        $input = 'http://' . $input;
    }
    
    $urlParts = parse_url($input);
    
    // remove www
    $domain = preg_replace('/^www\./', '', $urlParts['host']);
    
    echo $domain;
    
    // output: google.co.uk

    But where and especially how do I place this, so the URL showing on profiles will be shorter. Example:
    https://www.facebook.com/help/notifications > facebook.com/help/notifications
    We all know that http:// is back to the 90’s and www is gone in the most browsers, so why showing old URL’s, right?

    Only the showing URL and not the hardcoded URL 🙂

The topic ‘remove http://www. and https://www. from user website url info’ is closed to new replies.