Thursday, January 10, 2013

PHP Snippets


How to get domain without www/subdomains using php


<?php
     $host = $_SERVER['HTTP_HOST'];
     preg_match("/[^\.\/]+\.[^\.\/]+$/",$host,$matches);
     echo "domain name is :{$matches[0]}\n"};
?>