How to parse current page URL query parameters to create link using l() function I have a view in D7 with a few exposed filters.  This view generates a URL/page like this:  example.com/node?location=XXX&amp;check-in=XXX&amp;check-out=XXX&amp;lang=XXX.

I am looking to build a link passing in a couple of the current page's query parameters from above.  I am using the l() function and currently have the following:

print l("link_name","http://www.example.com/path", array('attributes'=&gt;array('target'=&gt;'blank'), 'query'=&gt;array('lang'=&gt;'en', 'currency'=&gt;'USD', 'standardCheckin'=&gt;$view-&gt;get_exposed_input(), 'standardCheckout'=&gt;$view-&gt;get_exposed_input())));


I am looking to pass in the check-in and check-out parameter values from the views-generated page in to my link function's standardCheckin and standardCheckout keys.  What I currently have obviously does not work.  I'm using the view::get_exposed_input function to pull in the values that are in the exposed filter, but it is pulling in ALL of the query parameters.  This function does not seem to have any query parameters to limit the query.  I also looked at using drupal_parse_url and drupal_get_query_parameters, but can not get those to work either (again, getting all parameters - can not limit to just the two I need).

I can pull the values from either the URL or from the exposed filter.  My PHP is a bit limited, but what is the best function to use (and a nudge syntactically on how to limit the query would be appreciated)?  Or is there a better Drupal method for achieving this?
Maybe something like this would be sufficient?

$url = drupal_parse_url('example.com/node?location=XXX&amp;check-in=XXX&amp;check-out=XXX&amp;lang=XXX.');
$desired_params = array_intersect_key($url['query'], array_flip(array('check-in', 'check-out')));


array_intersect_key() will return the values in the first array whose keys also exist in the second array, while array_flip() inverts the values in the array with their keys, actually generating something like the following (in my example):

array(
  'check-in' =&gt; 0,
  'check-out' =&gt; 1,
)


You can probably use the same approach or a very similar one with view::get_exposed_input, which is probably the best way of getting the data you need.



I didn't get that you also needed to rename the parameters. Then I don't think there's any advantage in filtering the parameters, just pull out the ones you need by hand.

$params = drupal_parse_url('...');
l("link_name","http://www.example.com/path",
  array('attributes' =&gt; array('target' =&gt; 'blank'),
  'query'=&gt;array(
    'lang' =&gt; 'en',
    'currency' =&gt; 'USD',
    'standardCheckin' =&gt; $params['query']['check-in'],
    'standardCheckout'=&gt;$params['query']['check-out']
   )
  )
);