Bilal Halayqa Bilal Halayqa - 6 months ago 34
PHP Question

Remove "www." from domain name string

How do I remove "www." from the url if it comes in the beginning only. -->

I have tried the following so far, but this removes the "www." if it is in any place :


Thanks in advance.

Answer Source
$a = "";
echo preg_replace ("~^www\.~", "", $a);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download