How To Remove Www From Domain Using Php

RegisterLogin
How To Remove Www From Domain Using Php
Post Description: How To Remove Www From Domain Using Php
Tags: How, To, Remove, Www, From, Domain, Using, Php
This Post Was Posted On Jul 28, 2009 By carlais #1384
hello webune,

today i was writing a simple php script and i wanted to know if you have come accross this.

you see, i have this site and i want to get the domain name using php in my code, but when i do the $_SERVER to get the hostname, i get the full www.example.com - and i only need the example.com part of it without the www.

what can i do?
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
webune
#3686 1
use the str_replace function in PHP

<?php
$domain = 'www.example.com';

$domain = str_replace("www.",'',$domain);

echo $domain ;
?>

OUTPUT:
example.com

try it
Apr 01, 2010 Reply Report abuse
Web Hosting Support
#1800 2
yes, i know what you mean,

i sent you the function you can use in php to get to do what you want on your script..

hope that helps
Jul 28, 2009 Reply Report abuse
©2011 Webune Forums - Mon Dec 19, 2011 12:42 am
Powered by: Webune Forums V3