fla5h
02-03-2003, 04:38 PM
I'm after a bit of help if someone can please lead me in the right direction.
I want a piece of PHP that will return me the host name of a url.
So
http://www.google.com/hello ..... = .... google.com
http://google.com/hello..... = .... google.com
www.google.com/hello..... = .... google.com
you get the picture ?
I have been trying to think of this logically ie
1. Search for 3rd '/' if it exists trim all to the right of it ( including '/' )
2. trim first 7 characters off the string.
3. Count the number of '.' in the string if more than one trim upto the first one.
So given
http://www.google.com/hello
step 1 = http://www.google.com
step 2 = www.google.com
step 3 = google.com
I cannot think of a better way ? Have I left a loop hole ?
If this follows through correctly, can someone let me know what I need to use in php to do this ?
Could do it in Javascript, but not php :(
Thanks for any guidance and help :)
I want a piece of PHP that will return me the host name of a url.
So
http://www.google.com/hello ..... = .... google.com
http://google.com/hello..... = .... google.com
www.google.com/hello..... = .... google.com
you get the picture ?
I have been trying to think of this logically ie
1. Search for 3rd '/' if it exists trim all to the right of it ( including '/' )
2. trim first 7 characters off the string.
3. Count the number of '.' in the string if more than one trim upto the first one.
So given
http://www.google.com/hello
step 1 = http://www.google.com
step 2 = www.google.com
step 3 = google.com
I cannot think of a better way ? Have I left a loop hole ?
If this follows through correctly, can someone let me know what I need to use in php to do this ?
Could do it in Javascript, but not php :(
Thanks for any guidance and help :)