Solved

How can I get all of URL parameters into one variable?

Posted on 2009-05-16
1
192 Views
Last Modified: 2012-08-13
Given the URL:
http://www.mysite.com/house/search_results.php?startdate=05%2F16%2F2009&enddate=05%2F23%2F2009&City=Lima&County=Allen

How can I get the entire URL parameter of "startdate=05%2F16%2F2009&enddate=05%2F23%2F2009&City=Lima&County=Allen" into a variable using PHP?

This is necessary because the page includes column headings that the user can click on the sort table data, but unless I keep the existing URL parameters - they are erased by the new sort URL parameter - if that makes sense.
0
Comment
Question by:oh_maestro
1 Comment
 
LVL 7

Accepted Solution

by:
tg_wilk earned 50 total points
ID: 24403576
You can use foreach and $_GET to do that:
<?php

$params = array();

foreach ($_GET as $key=>$val)

  $params[] = urlencode($key).'='.urlencode($val);

$result = implode('&',$params);

?>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php date - compare 4 40
PHPStorm debugging issues 1 25
mysqli 3 22
WordPress website error - Unable to access website. 5 34
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now