I want to get Get Domain from URL and be output: http://www.domain.com/
I found this, but does not come out with the http://
<?php
$url = 'http://www.lebanonpost.com/2012/05/20/press-754/';
$parse = parse_url($url);
$domain = str_ireplace('www.', '', parse_url($url, PHP_URL_HOST));
print $parse['host']; // prints 'google.com'
?>
Output: www.lebanonpost.com
I want it to be: http://www.lebanonpost.com/
Try:
It will work if there is
https
instead ofhttp
Test Here