slimjim Posted August 1, 2007 Share Posted August 1, 2007 I am using this: $url = (strstr($_POST["websiteurl"],"http://")!=""?"":"http://").$_POST["websiteurl"]; Only problem is that it not working correctly the way I need it too. Oh it replaces the http:// if not there, but if a person forgets the :// or just the //, it adds the http:// to it anyway so I could end up with http://http: I need help on this so in end result, of regardless of what they missed i has http"// PLease help Quote Link to comment Share on other sites More sharing options...
effigy Posted August 1, 2007 Share Posted August 1, 2007 So do you need something along the lines of a validator? See this topic. Quote Link to comment Share on other sites More sharing options...
slimjim Posted August 1, 2007 Author Share Posted August 1, 2007 Well actually I need it to see if any part of http:// is missing and then replace it if it is Quote Link to comment Share on other sites More sharing options...
slimjim Posted August 1, 2007 Author Share Posted August 1, 2007 does anyone know how to do this ? Quote Link to comment Share on other sites More sharing options...
effigy Posted August 1, 2007 Share Posted August 1, 2007 Have some patience please. <pre> <?php $tests = array( 'http://www.url.com', 'url.com', 'httpurl.com', 'http:url.com' ); foreach ($tests as $test) { echo $test, ' => '; echo preg_replace('#^(?:http:?(?://)?)?#', 'http://', $test); echo '<br>'; } ?> </pre> 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.