JJBlaha Posted December 17, 2006 Share Posted December 17, 2006 I want to have a user input their website, and if they do not put http:// before it, i want the script to add it. If they did put it, then i want it unchanged. For example an input of www.phpfreaks.com should output as http://www.phpfreaks.com. Anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
matto Posted December 17, 2006 Share Posted December 17, 2006 combination of if, substr(), and substr_replace() should do the trick Quote Link to comment Share on other sites More sharing options...
JJBlaha Posted December 18, 2006 Author Share Posted December 18, 2006 could you give me an example of how that might look? i have never used substr or strstr before. Quote Link to comment Share on other sites More sharing options...
chiprivers Posted December 18, 2006 Share Posted December 18, 2006 <?phpif(substr($string,0,7) = "http://") { // leave $string as is} else { $string = "http://".$string;}?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.