Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 296697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:34:20+00:00 2026-05-12T06:34:20+00:00

The page: /index.php?page=6&test=1&test2=2 The code below strip’s page=6 off of this so I can

  • 0

The page: /index.php?page=6&test=1&test2=2

The code below strip’s page=6 off of this so I can add our new page to the url and add the $url_without_page_var back to our link again:

$_SERVER['argv'][0]
// Displays:   page=6&test=1&test2=2

And

 $url_without_page_var=preg_replace('/page=(\d+)/i','',$_SERVER['argv'][0]);
// Displays: &test=1&test2=2

Ok so that code lets me take the page=6 off of page=6&test=1&test2=2
I can then change the page number and add this all back together.

My problem is often the page in the URL will not always be in the same position, it may not be the 1st or last items
And this is what will happen when, see how the URL is incorrect now;

/page.php?&**test=1&test2=2 **ERROR-HERE-ALSO page=9

Is it possible to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:34:21+00:00Added an answer on May 12, 2026 at 6:34 am

    The $_GET variable provides an array of all the variables set through the URL. $_REQUEST is an array of all the GET and POST variables set. Here’s the fish:

    $url_string = "index.php?";
    foreach( $_GET as $k => $v ){
        if( $k != "key_you_dont_want"){ // <-- the key you don't want, ie "page"
            if( $url_string != "index.php?" )
                $url_string .= "&"; // Prepend ampersands nicely
            $url_string .= $k . "=" . $v;
        }
    }
    

    Regex is a bit overkill for this problem.
    Hope it makes sense. I’ve been writing Python and Javascript for the past few weeks. PHP feels like a step backwards.

    EDIT: This code makes me happier. I actually tested it instead of blindly typing and crossing fingers.

    unset( $_GET["page"] );
    
    $c = count($_GET);
    $amp = "";
    $url_string = "test.php";
    
    if( $c > 0 ) {
        $url_string .= "?";
        foreach( $_GET as $k => $v ){
            $url_string .= $amp . $k . "=" . $v;
            $amp = "&";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have folders and pages /admin/add/index.php, /admin/edit/index.php & /admin/view/index.php which all are requiring page
Take a look at this page: http://jqeedu.tuxfamily.org/test/index.php . You'll see a < between the
On this site: http://www.seleconlight.com everything is fine On this url: http://www.seleconlight.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=shop.flypage.p3&category_id=8&product_id=21 most people get
I have this problem. When you visit page where is PHP code: $_SESSION['test']++; echo
this is the first page : index.html <!DOCTYPE html> <html> <head> <link rel=stylesheet href=../test/style.css>
<?php echo $this->getUrl(); ?> gives me my index page url .i.e. www.domain.com/index.php/ But now,
I have a page index.php that uses a modal to upload files. After those
I have an index page index.php , and when the user clicks on a
I have a page index.php where i have a link called add_users.php. In add_users.php,
I have a index.php page that is the main page. All pages are included

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.