Solved

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

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

746 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

14 Experts available now in Live!

Get 1:1 Help Now