PDA

View Full Version : how i can Extracting the domain


qwe010
4th October 2008, 04:28
hello

how i can Extracting the domain

from link like that

http://www.phpbuilder.com/board/
and
http://sub.phpbuilder.com/board/

i try with strstr


if ( strstr($site, "www") ){

$ilk = strpos($site, ".");
$orta = substr($site, $ilk+1);
$ilkson = strpos($orta, "/");
$orta = substr($site, $ilk+1, $ilkson+1);

$uzunluk = strlen($orta);
$son = substr($orta, $uzunluk-1);

if ($son == "/"){
$ss = substr($orta, 0, $uzunluk-1);
} else {
$ss = $orta;
}

But not work Correctly

Especially with the short domain

any idea ?

falko
4th October 2008, 15:05
What exactly are you trying to do?

qwe010
4th October 2008, 17:31
i want to write script ( add sites )
http
ftp
ip

and count the sites with sub domain and without

falko
5th October 2008, 20:51
You can check out the parse_url() function: http://de2.php.net/manual/en/function.parse-url.php