Welcome to WebmasterWorld Guest from 18.104.22.168 , register , login , search , subscribe , help , library , PubCon , announcements , recent posts , open posts Pubcon Platinum Sponsor
remove www. only if it exists martymac msg:3999962 3:05 pm on Oct 2, 2009 (gmt 0) I have an list/array of URL's that are going to be stored in a DB:
www.example2.com example3.org example4.net www.example6.edu
How would I parse the URLs so that the "www." is removed from any domains that contain it, and the rest of the domains are not modified. The results should look like:
example2.com example3.org example4.net example6.edu
jd01 msg:3999987 3:40 pm on Oct 2, 2009 (gmt 0)
You would probably use something like str_replace() or substr_replace() depending on your exact application... If you need to replace all sub domains, not just www you would probably have to graduate to preg_replace and stay away from ereg_replace it runs on a different regex engine than preg_replace and isn't anywhere near as fast.
...] us2.php.net [ ...]
us2.php.net martymac msg:3999994 4:01 pm on Oct 2, 2009 (gmt 0)
Figured it out, thanks!