Welcome to WebmasterWorld Guest from 34.238.192.150

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Pulling the domain from a url

getting domain from url stored in mysql

     
6:55 pm on Dec 21, 2005 (gmt 0)

New User

10+ Year Member

joined:Aug 25, 2005
posts:12
votes: 0


I have a table called survey an in it is a field called URL. I am trying to display on a page just the domain from the URL that is in that field. so http://www.example.com/index.php would equal either www.example.com or example.com (either would be fine, I am not picky) SO far none of my attempts have come close to working, so I am not sure how a I should go about doing this. Any suggestions?

[edited by: jatar_k at 7:01 pm (utc) on Dec. 21, 2005]
[edit reason] examplified [/edit]

7:02 pm on Dec 21, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


would this help?

[php.net...]

7:11 pm on Dec 21, 2005 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member ogletree is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 14, 2003
posts:4320
votes: 42


<?php
preg_match("/^(http:\/\/)?([^\/]+)/i", $URLstring, $result);
$domain = $result[2];
?>