I need a PHP-script that shows/prints different strings depending on whether the current document is on a domain or subdomain. If it is on a subdomain it is to print different string depending on the first letter (a-z), if not a-z then yet another string is to be printed. The script must be tolerant to whether "www" is used or not. I need it ASAP. $10 thru paypal.
i am not exper but i think this can be done by something like this $exploded= explode (".", $array); Code (markup): then u need to add something which will automatically print out if the $explode[3] exists or not? if it exists then it means that it is a subdomain otherwise domain
# Find subdomain preg_match('@^(www\.)?(.*)yourdomain\.com$@i',$_SERVER['HTTP_HOST'],$tmp); $sub = empty($tmp[2]) ? false : $tmp[2]; unset($tmp); if ( $sub ) { # Subdomain - extract first character $first = substr($sub,0,1); if ( ctype_alpha($first) ) # First char is A-Z include 'subdomaina-z.html'; else # First char is not A-Z include 'subdomainnota-z.html'; } else { # Main domain include 'maindomain.html'; } PHP: Untested but should be something along those lines.