I'm with the code:
function addhttp($url){
if(!preg_match('~^(http)s?://~i', $url)){
$url = 'http://'.$url;
}
return $url;
}
It will add HTTP if the URL you entered does not contain it, but what I'm in doubt is the ~ issue you have at the beginning and then at the end ~ i . I would like to know what this is for.