Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 94473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:30:25+00:00 2026-05-10T23:30:25+00:00

I have a PHP application that will on occasion have to handle URLs where

  • 0

I have a PHP application that will on occasion have to handle URLs where more than one parameter in the URL will have the same name. Is there an easy way to retrieve all the values for a given key? PHP $_GET returns only the last value.

To make this concrete, my application is an OpenURL resolver, and may get URL parameters like this:

ctx_ver=Z39.88-2004 &rft_id=info:oclcnum/1903126 &rft_id=http://www.biodiversitylibrary.org/bibliography/4323 &rft_val_fmt=info:ofi/fmt:kev:mtx:book &rft.genre=book &rft.btitle=At last: a Christmas in the West Indies.  &rft.place=London, &rft.pub=Macmillan and co., &rft.aufirst=Charles &rft.aulast=Kingsley &rft.au=Kingsley, Charles, &rft.pages=1-352 &rft.tpages=352 &rft.date=1871 

(Yes, I know it’s ugly, welcome to my world). Note that the key ‘rft_id’ appears twice:

  1. rft_id=info:oclcnum/1903126
  2. rft_id=http://www.biodiversitylibrary.org/bibliography/4323

$_GET will return just http://www.biodiversitylibrary.org/bibliography/4323, the earlier value (info:oclcnum/1903126) having been overwritten.

I’d like to get access to both values. Is this possible in PHP? If not, any thoughts on how to handle this problem?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:30:26+00:00Added an answer on May 10, 2026 at 11:30 pm

    Something like:

    $query  = explode('&', $_SERVER['QUERY_STRING']); $params = array();  foreach( $query as $param ) {   // prevent notice on explode() if $param has no '='   if (strpos($param, '=') === false) $param += '=';    list($name, $value) = explode('=', $param, 2);   $params[urldecode($name)][] = urldecode($value); } 

    gives you:

    array(   'ctx_ver'     => array('Z39.88-2004'),   'rft_id'      => array('info:oclcnum/1903126', 'http://www.biodiversitylibrary.org/bibliography/4323'),   'rft_val_fmt' => array('info:ofi/fmt:kev:mtx:book'),   'rft.genre'   => array('book'),   'rft.btitle'  => array('At last: a Christmas in the West Indies.'),   'rft.place'   => array('London'),   'rft.pub'     => array('Macmillan and co.'),   'rft.aufirst' => array('Charles'),   'rft.aulast'  => array('Kingsley'),   'rft.au'      => array('Kingsley, Charles'),   'rft.pages'   => array('1-352'),   'rft.tpages'  => array('352'),   'rft.date'    => array('1871') ) 

    Since it’s always possible that one URL parameter is repeated, it’s better to always have arrays, instead of only for those parameters where you anticipate them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a PHP application that will have the ability to edit settings
I have a php application that sometimes creates two lightboxes on the same page
I'm writing a PHP application that manages some LDAP entries. I have one page
I have a PHP application that will be accepting image uploads and I'm expecting
I have a PHP application that currently has 5k users and will keep increasing
I'm building a php application that will have many modules/plugins. The issue is that
I have a PHP application that will be accessed by users who are already
I would like to make a web application (PHP) that will have overlay container
This is the first time I'll be making a PHP application that will have
I'm starting a new application that will have a server side PHP and client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.