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 Link to comment https://forums.phpfreaks.com/topic/62871-strstr-or-something/ 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. Link to comment https://forums.phpfreaks.com/topic/62871-strstr-or-something/#findComment-312987 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 Link to comment https://forums.phpfreaks.com/topic/62871-strstr-or-something/#findComment-313005 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 ? Link to comment https://forums.phpfreaks.com/topic/62871-strstr-or-something/#findComment-313074 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> Link to comment https://forums.phpfreaks.com/topic/62871-strstr-or-something/#findComment-313118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.