Solved

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

Posted on 2009-05-16
1
195 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

830 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