homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Top level Domain From a link?
havoc




msg:1263769
 12:54 am on Jul 30, 2003 (gmt 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

 

smokin




msg:1263770
 1:18 am on Jul 30, 2003 (gmt 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 ]

Timotheos




msg:1263771
 5:05 am on Jul 30, 2003 (gmt 0)

I think parse_url() [us2.php.net] is what you're after.

havoc




msg:1263772
 5:52 am on Jul 30, 2003 (gmt 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

vincevincevince




msg:1263773
 12:54 pm on Jul 30, 2003 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved