Solved

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

Posted on 2009-05-16
1
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

626 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