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.
 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=view 
All 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

Popular posts from this blog

What Are The Main Components of a Computer System

Top Qualities To Look For In An IT Support Team

How To Integrate Google Adwords Api Into Codeigniter?