Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 08 October 2006 - 09:47 PM

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.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 08 October 2006 - 09:52 PM

if (!strstr($url,'http://')) {
  $url = 'http://'.$url;
}


#3 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 08 October 2006 - 10:23 PM

thx. i revised it a bit so it checks if the user inputs just www.google.com or google.com

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users