Last active
January 31, 2018 17:24
-
-
Save nhalstead/8e14b1748f91e086479c20be1a18f403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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