Search
 
SCRIPT & CODE EXAMPLE
 

PHP

remove get parameters from url php

function strip_param_from_url( $url, $param ) {
    $base_url = strtok($url, '?');              // Get the base url
    $parsed_url = parse_url($url);              // Parse it 
    $query = $parsed_url['query'];              // Get the query string
    parse_str( $query, $parameters );           // Convert Parameters into array
    unset( $parameters[$param] );               // Delete the one you want
    $new_query = http_build_query($parameters); // Rebuilt query string
    return $base_url.'?'.$new_query;            // Finally url is ready
}
// Usage
echo strip_param_from_url( 'http://url.com/search/?location=london&page_number=1', 
	'location' )
Comment

php remove all parameter from url

 $url = strtok($url, '?');
Comment

PREVIOUS NEXT
Code Example
Php :: log magento 2.4.3 
Php :: php loop backwards through array 
Php :: wp_query post by category id 
Php :: mysql server has gone away php 
Php :: webstorm vs phpstorm 
Php :: convert object to array laravel 
Php :: codeigniter form_validation email 
Php :: codeigniter query builder order by 
Php :: insert php variable css 
Php :: laravel drop column if exists 
Php :: how to override default name for apiresourc route in laravel 
Php :: laravel create migration add column 
Php :: get original name without mutant model laravel 
Php :: php serialize 
Php :: Get date without time in laravel 
Php :: php remove warning 
Php :: sentence get first second word php laravel 
Php :: laravel blade time difference 
Php :: order number generate laravel 
Php :: php mkdir recursive 
Php :: mac os change the php verison 
Php :: convert string to array laravel 
Php :: get domain name laravel 
Php :: while loop php 
Php :: php number positive 
Php :: wp wordpress logout 
Php :: laravel instal 
Php :: php remove prefix from string 
Php :: php set global variables from function 
Php :: Could not find package laravel/ with stability stable. 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =