I need to remove www from the string given by $_SERVER['HTTP_HOST']
How can I do that in PHP?
$server_name = str_replace("www.", "", $_SERVER['HTTP_HOST']);
That should do the trick...
if (substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.') {
$domain = substr($_SERVER['HTTP_HOST'], 4);
} else {
$domain = $_SERVER['HTTP_HOST'];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With