Are you looking to parse Domain Name from Current URL ? If yes than you don’t need to use explode function. There is other easy way to parse domain name, website url from current url of page. You can parse the domain name using explode function as well but this is the easy way to get domain name from url. Please have a look and let me know which is easy way to get domain name from URL. 🙂
<?php $current_web_url = "http://www.phpfreelancedevelopers.com/product.php?id=1"; $currenturlarr = parse_url($current_web_url); print_r($currenturlarr); ?>
If you look at the results, You can see below result.
[scheme] => 'http' [url] - 'www.phpfreelancedevelopers.com' [path] - '/product.php' [query] - 'id=1'