示例为1,如果它以
开头
//host/data/user/temp/data.text希望将其设为“file:// host / data / user ...”
示例:对于2,如果它以
开头
谷歌我想把它变成“html://Google.com”
答案 0 :(得分:-1)
Try this.
$subject = 'filename';
//$subject = '//filename';
if(preg_match("/^\/\//", $subject)){
//$newstring= preg_replace("/^\/\//", "file://", $subject);
$newstring= "file:".$subject;
}else{
$newstring= "http://".$subject;
}