Welcome to WebmasterWorld Guest from 54.145.53.251

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Top level Domain From a link?

     
12:54 am on Jul 30, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 28, 2002
posts:79
votes: 0


Just a quick question i did some googling and it hasnt come up with anything yet. Obviously im looking for the wrong thing

Basically i want to get a top level domain out of a refer link so i can write me refers list. for example if the refer came from [widgetz.com...]
How do i use php to extract the [widgetz.com...] and kill the rest?

Thanks

1:18 am on July 30, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:July 3, 2002
posts:82
votes: 0


I would use regular expressions to extract the tld from a url. Here is a site that has many free regexes. It probably has the one you want:
[regexlib.com ]
5:05 am on July 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2003
posts:775
votes: 0


I think parse_url() [us2.php.net] is what you're after.
5:52 am on July 30, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 28, 2002
posts:79
votes: 0


thanks

i used this example (

Example:
$url=parse_url(http://www.widget.net/download-php.php3?csel=br);

$url[scheme] = http
$url[host] = www.widget.net
$url[path] = /download-php.php3
$url[query] = csel=br

works good

12:54 pm on July 30, 2003 (gmt 0)

Senior Member from MY 

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 1, 2003
posts:4847
votes: 0


<?php
echo preg_replace("/^(http:\/\/[^\/]*).*/i","$1",$fullurl);
?>
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members