Created
August 7, 2018 08:59
-
-
Save ahkmunna/883b635e6f438e253837a1b6ea13307a to your computer and use it in GitHub Desktop.
Remove parameter from the URL query string.
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
if ( ! function_exists('remove_url_parameter') ) | |
{ | |
/** | |
* Remove given parameter from the given url str | |
*/ | |
function remove_url_parameter($url, $key = false) | |
{ | |
return preg_replace( '/'. ($key ? '(\&|)' . $key . '(\=(.*?)((?=&(?!amp\;))|$)|(.*?)\b)' : '(\?.*)').'/i' , '', $url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment