Dear All, I have this problem, please help me. I want to replace www.google.com to http://www.google.com.com by using function preg_replace(), but i don't know how to do. Thanks
$tring = 'hey search for stuff at www.google.com'; $pat = '/www\.google\.com/'; $replace = 'http://www.google.com'; $new_string = preg_replace ($pat, $replace, $tring); echo $new_string; PHP:
Thanks, what about if i want to change other word that not specific when user type the website with http:// example: www.google.com,www.yahoo.com,...................... Thanks
Do you mean you just want to add http:// onto whatever variable? for that just use the .= operator. $url = 'http://'; $url .= 'www.google.com'; The output of $url will now be http://google.com
Yes i mean like that, i mean that the variable depend on input if they type www.google.com it will convert to http://www.google.com, if www.yahoo.com it will convert to http://www.yahoo.com........... thanks