Jump to content

Recommended Posts

Hi all,

 

I need to strip out the "pagenumber" param from the following query string:

 

search.php?pagenumber=2&param0=a

 

I have a search script which is passing any seach params dynamically.  So both these query strings are searching for the letter 'a'.  The problem is that the pagenumber is passed around so it creates another param for it each time the "next page" link is clicked and it screws up the search.

 

search.php?pagenumber=2&param0=2&param1=a

 

Can anyone help with this one? What string functions would be best for this?

 

 

Thanks in advance.

 

CC :)

I tried that function using the following code:

 

public function removeParam($param){
parse_str($this->_querystring,$output);
unset($output[$param]);
return $output;
}

 

I didn't get the desired results as it still creates the 2nd query string.

Alternately

 

<?php

$test = 'search.php?pagenumber=2&param0=a';
list(,$query) = explode( '?', $test );
parse_str( $query, $qVars );

echo $qVars['pagenumber'];

?>

 

Saves you a parse_url call.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.