Skip to content

Instantly share code, notes, and snippets.

@nhalstead
Last active January 31, 2018 17:24
Show Gist options
  • Save nhalstead/8e14b1748f91e086479c20be1a18f403 to your computer and use it in GitHub Desktop.
Save nhalstead/8e14b1748f91e086479c20be1a18f403 to your computer and use it in GitHub Desktop.
<?php
$allowed = array("https", "http");
function protocolRegex($array){
if(empty($array)) { return "(\/\/)"; }
foreach($array as $i => $v){
if(empty($v)){
unset($array[$i]);
}
}
$array = implode("|", $array);
return "((".$array."):|\/\/)";
}
echo protocolRegex($allowed);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment