emma57573 Posted March 30, 2009 Share Posted March 30, 2009 What Im trying to do is if somebody types in www.theirdomain It removes the www. part and they are just left with theirdomain MY Code $domain=$_REQUEST["domain"]; $patterns[0] = '/www./'; $replacements[0] = ''; preg_replace($patterns, $replacements, $domain); It outputs www.theirdomain so does not remove the www. bit as I want it to? Any ideas where I am going wrong? Link to comment https://forums.phpfreaks.com/topic/151711-solved-cant-seem-to-get-preg_replace-to-work/ Share on other sites More sharing options...
emma57573 Posted March 30, 2009 Author Share Posted March 30, 2009 Ive now tried taking out the slashes and got this error [phpBB Debug] PHP Notice: in file /home/misimeuk/public_html/store_infotest.php on line 31: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash Does that mean I cant use preg_replace with a '.' :-\ Link to comment https://forums.phpfreaks.com/topic/151711-solved-cant-seem-to-get-preg_replace-to-work/#findComment-796698 Share on other sites More sharing options...
emma57573 Posted March 30, 2009 Author Share Posted March 30, 2009 Ive fixed this with the following: $domain=$_REQUEST["domain"]; $patterns = "www."; $replacements = ""; $domain = str_replace($patterns, $replacements, $domain); Sometimes just writing out te question helps you think with a clear head Link to comment https://forums.phpfreaks.com/topic/151711-solved-cant-seem-to-get-preg_replace-to-work/#findComment-796702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.