Solved

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

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

803 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