Hi,
I have this snippet:
// Returns array of vals. Ex: array("www", "example", "com");
$host = explode(".", $_SERVER['HTTP_HOST'], 2);
// or to pass in a supplied host
function parseDomainName($host) {
$pHost = explode(".", $host, 2);
return $pHost[1];
}
// loop through the link array, outputting the URL + Link Text
for ($i = 0; $i < sizeof($linkarray[0]); $i++){
echo (" " . $linkarray[2][$i] . " - <a href=" . $linkarray[1][$i] . "> Link " . $i . "</a><br>");
// In case you want this as well.
// Returns array of parsed request uri. Ex: array("path" => "/blog")
$uri = parse_url($_SERVER['REQUEST_URI']);
//print_r ($host[1]);
print_r (parseDomainName($linkarray[1][$i]));
//print_r ($uri);
}
Everything works fine, except when it turns full length URLs into the domain and extension, it keeps the subdirectories. Example:
http://www.google.com/search.php
is turned into:
google.com/search.php
It should be shown as:
google.com
Help as to how to cut the
/blah....
out would be greatly appreciated,
Thanks,
Lee.