How To Take Away Enquiry String From Url Inwards Php?
Today I needed to take away the enquiry string or parameter from the URL. I flora this quick constituent which does just what i needed i.e take away enquiry string from URL.
Thanks to http://davidwalsh.name/php-remove-variable Sumber http://developer-paradize.blogspot.com
constituent remove_qs_key($url, $key) { render preg_replace(‘/(?:&|(\?))’ . $key . ‘=[^&]*(?(1)&|)?/i’, “$1″, $url); }For example, if your URL was this:
$url = http://example.com/test/index?id=55&template=view&format=pdf $key = 'format';The inwards a higher house constituent would return:
echo remove_qs_key($url, $key); //output: http://example.com/test/index?id=55&template=viewAll I needed to produce was furnish the URL too the fundamental to take away -- then tardily too uncomplicated :)
Thanks to http://davidwalsh.name/php-remove-variable Sumber http://developer-paradize.blogspot.com
Comments
Post a Comment