Answers for "'https://', 'www.' & all sub derictories reomve from a url with regex"

PHP
1

'https://', 'www.' & all sub derictories reomve from a url with regex

<?php

    $url = "https:// http://www.app.azonedev.com/somet hing/nothi
    ng";
    $url_to_main_domain = preg_replace('/(https|http|:|\/\/|www.|\s)/i','',$url);
    $remove_sub_dir_from_url = preg_replace('/(\/).*/','',$url_to_main_domain);
    echo $remove_sub_dir_from_url;
Posted by: Guest on February-28-2021

Code answers related to "'https://', 'www.' & all sub derictories reomve from a url with regex"

Browse Popular Code Answers by Language