Bilal Halayqa Bilal Halayqa - 1 month ago 5
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);