Hi, I am modifying a whois script. I am currently using the following code to detect the www.xxx.com format and transfer it into xxx.com if(isset($_GET['query'])){ $query = str_replace("www.","",$_GET['query']); But if I am checking a domain e.g. xxxwww.com, it will also be replaced and changed to xxx.com How to solve this problem? I am not into coding, so please if anyone can help me to find a simple solution. Thanks
Thanks, php-lover, but it doesnt work, as if the actual domain is aboutwww.com, it will replace the domain to aboutcom which causes error.
okay then take off the dot. try this one. if(isset($_GET['query'])){ $query = preg_replace('/www/','',$_GET['query']);
Do something like this man... <?php if(isset($_GET['query']) && substr($_GET['query'], 0, 4) == 'www.') { $query = substr($_GET['query'], 4); } echo $query; ?>