Skip to content

Instantly share code, notes, and snippets.

@srcoley
Created March 20, 2012 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srcoley/2138263 to your computer and use it in GitHub Desktop.
Save srcoley/2138263 to your computer and use it in GitHub Desktop.
refer_id_filter - changes the referid of any given url
<?php
function referid_filter($url, $refer_id) {
$regex = "%http[s]*\:\/\/www\.hccmis\.com\/[\w-\/]+\?referid=(\d*)%";
if(preg_match($regex, $url, $matches)) {
if($matches[1] == "") {
return $url . $refer_id;
} else {
$url_arr = explode("?referid=", $url);
return $url_arr[0] . "?referid=" . $refer_id;
}
} else {
return false;
}
}
echo referid_filter("https://www.hccmis.com/atlas-travel-insurance-quote/atlas_travel/?referid=12352342", "000000");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment