Jump to content

Archived

This topic is now archived and is closed to further replies.

newb

convert url's to http:// ???

Recommended Posts

how do i convert google.com or if the user inputs www.google.com to http:// or if they already have http:// it wont add the extra http:// like in vbulletin?? does anyone know how i been trying to figure it out i dont kno how to do it someone pleeze give me example pls help thanks im new at php idk where 2 start.

Share this post


Link to post
Share on other sites
[code=php:0]
if (!strstr($url,'http://')) {
  $url = 'http://'.$url;
}
[/code]

Share this post


Link to post
Share on other sites
thx. i revised it a bit so it checks if the user inputs just www.google.com or google.com

[code]
<?php
if (!strstr($url,'http://')) {
if (strstr($url,'www')) {
$url = 'http://'.$url;
} else {
    $url = 'http://www.'.$url;
  }
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.