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 :: php loop through months 
Php :: check php version mac 
Php :: what sign is less than or equal to php 
Php :: laravel form submit page expired 
Php :: set null on foreign key deletion in laravel 
Php :: PHP strlen — Get string length 
Php :: alert a php variable 
Php :: laravel optional route parameter in middle of url 
Php :: check php version linux terminal 
Php :: php divide string into parts 
Php :: php create Hmac sha256 
Php :: wpml language switcher shortcode 
Php :: wordpress wp_head 
Php :: laravel make model and migration 
Php :: error reporting on php 
Php :: string to array in laravel 
Php :: laravel faker examples 
Php :: php while loop array 
Php :: get ip in laravel 
Php :: php base64 encoded image to png 
Php :: laravel clear table 
Php :: delete file laravel 8 
Php :: first item in array php 
Php :: pdo php check if row exist 
Php :: laravel $loop interation 
Php :: redirect from controller in laravel 
Php :: share link in facebook php 
Php :: get number of chars ina string php 
Php :: overwrite file php 
Php :: Pacific Daylight Time Zone php 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =