function add_protocol($url,$protocol='http://'){ if (preg_match('#^([ftphs]+://)([^ ]+)#',$url,$results)){return $url;}else{return $protocol.$url;} }