I have this code :

$string = $_SERVER['HTTP_HOST'];
echo ucfirst($string); // Capitalize 1st
Can someone tell me what to add to this code to remove "www" behind.

If i access my domain.com will show Domain.com but if i access www.domain.com will show Www.domain.com.

How to modify the code to remove www. when i access my domain using www.domain.com .