Currently I am using following function
preg_match("/^(http:\\/\\/)?([^\\/]+)/i", $_SERVER['HTTP_HOST'], $matches); $host = $matches[2]; // get last two segments of host name preg_match("/[^\\.\\/]+\\.[^\\.\\/]+$/", $host, $matches); echo "domain name is: {$matches[0]}\ ";
output of this function is
but i want following outout: abc
anyone can help me?
Bear in mind, ereg_replace has been deprecated. You might want to consider using preg_replace instead.
Thanks
Solution:
$name = ereg_replace( "^(www.)?([^.]+).[^.]+$", "\\\\2", $_SERVER['HTTP_HOST'] );
domain:
output: abc
Why don’t you post the solution, for the benefit of others that might have the same problem?
Got the solution… Mod please close this thread