You could use a function ... for example:
<?php
function format_url($url){
if(substr($url, 0, 7) != 'http://'){
if(substr($url, 0, 5) == 'http:'){
return 'http://'.substr($url, 5);
} else {
return 'http://'.$url;
}
}
return $url;
}
?>
Of course, you could still have problems if the user made a different input error (eg. 'htp://'). You could extend the function to cover all possibilities, but there are quite a few to deal with!!
Trouble is, in my experience, if a user can do something wrong, they will (eventually, at least). So, don't use a method like this in your app if the app depends on the user input being correct (or at least correctable).
P.