Извлечение имени сайта из URL
Пример:
<?php
$text="http://www.example.com/path/path/index.html?id=123";
preg_match('/(http|https|ftp):\/\/([^\/]+)(.*)/i',$text,$result);
var_dump($result);
?>
Результат:
array(4) {
[0]=>
string(50) "http://www.example.com/path/path/index.html?id=123"
[1]=>
string(4) "http"
[2]=>
string(15) "www.example.com"
[3]=>
string(28) "/path/path/index.html?id=123"
}
03.02.2007
