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

  • Home
  • SEARCH
  • 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

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?

  • 0 0 Answers
  • 0 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

Ask A Question

Stats

  • Questions 79k
  • Answers 79k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should be able to Edit the fonts and colors… May 11, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer The ZedGraphControl allows Pan & Zoom to be controlled through… May 11, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer The connection string should look something like: < add name="MyConnectionString"… May 11, 2026 at 4:05 pm

Related Questions

I wrote a small PHP application that I'd like to distribute. I'm looking for
I'm about to start working on a PHP application that allows a user to
Once in a while my shared hosting environment gets compromised because, well, I failed
I have a few classes, such as those that outline database table structure or

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.