Forum Moderators: coopster

Message Too Old, No Replies

Check variable to see if it starts with "www."

if so add "http://" to the beginning to complete link

         

wfernley

3:22 pm on Aug 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the title explains it all. If I have a variable that a user entered that is "www.mysite.com" and I want it to be "http://www.mysite.com" how would I see what the variable starts with so I can tell if I should add http:// to the beginning.

I hope this is an easy answer :)

Thanks!

Wes

arran

3:35 pm on Aug 26, 2005 (gmt 0)

10+ Year Member



Hi Wes,

if (preg_match('/^www/', $your_string)) {
$your_string .= "http://";
}

wfernley

5:27 pm on Aug 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great Thanks arran. It worked great.

Wes