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 7585453
In Process

The Archive Base Latest Questions

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

Is there a standard way of passing an array through a query string? To

  • 0

Is there a standard way of passing an array through a query string?

To be clear, I have a query string with multiple values, one of which would be an array value. I want that query string value to be treated as an array- I don’t want the array to be exploded so that it is indistinguishable from the other query string variables.

Also, according to this post answer, the author suggests that query string support for arrays is not defined. Is this accurate?

EDIT:

Based on @Alex’s answer, there is no standard way of doing this, so my follow-up is then what is an easy way to recognize that the parameter I’m reading is an array in both PHP and Javascript?

Would it be acceptable to name multiple params the same name, and that way I would know that they belong to an array? Example:

?myarray=value1&myarray=value2&myarray=value3...

Or would this be a bad practice?

  • 1 1 Answer
  • 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. Editorial Team
    Editorial Team
    2026-05-30T19:10:49+00:00Added an answer on May 30, 2026 at 7:10 pm

    Here’s what I figured out:

    Submitting multi-value form fields, i.e. submitting arrays through GET/POST vars, can be done several different ways, as a standard is not necessarily spelled out.

    Three possible ways to send multi-value fields or arrays would be:

    • ?cars[]=Saab&cars[]=Audi (Best way- PHP reads this into an array)
    • ?cars=Saab&cars=Audi (Bad way- PHP will only register last value)
    • ?cars=Saab,Audi (Haven’t tried this)

    Form Examples

    On a form, multi-valued fields could take the form of a select box set to multiple:

    <form> 
        <select multiple="multiple" name="cars[]"> 
            <option>Volvo</option> 
            <option>Saab</option> 
            <option>Mercedes</option> 
        </select>
    </form>
    

    (NOTE: In this case, it would be important to name the select control some_name[], so that the resulting request vars would be registered as an array by PHP)

    … or as multiple hidden fields with the same name:

    <input type="hidden" name="cars[]" value="Volvo">
    <input type="hidden" name="cars[]" value="Saab">
    <input type="hidden" name="cars[]" value="Mercedes">
    

    NOTE: Using field[] for multiple values is really poorly documented. I don’t see any mention of it in the section on multi-valued keys in Query string – Wikipedia, or in the W3C docs dealing with multi-select inputs.


    UPDATE

    As commenters have pointed out, this is very much framework-specific. Some examples:

    Query string:

    ?list_a=1&list_a=2&list_a=3&list_b[]=1&list_b[]=2&list_b[]=3&list_c=1,2,3
    

    Rails:

    "list_a": "3", 
    "list_b":[
        "1",
        "2",
        "3"
      ], 
    "list_c": "1,2,3"
    

    Angular:

     "list_a": [
        "1",
        "2",
        "3"
      ],
      "list_b[]": [
        "1",
        "2",
        "3"
      ],
      "list_c": "1,2,3"
    

    (Angular discussion)

    See comments for examples in node.js, WordPress, ASP.net


    Maintaining order:
    One more thing to consider is that if you need to maintain the order of your items (i.e. array as an ordered list), you really only have one option, which is passing a delimited list of values, and explicitly converting it to an array yourself.

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

Sidebar

Related Questions

Is there a standard way to do an fopen with a Unicode string file
Is there a standard way to bind arrays (of scalars) in a SQL query?
Is there a standard way to associate version string with a Python package in
Is there a standard way of maintaining a weak pointer to a parent (which
Is there a standard way / C# library to convert a string into a
What's the standard way of passing and processing an array in an HTTP request
Is there a standard way to convert an XSD to an input form (ASP.NET
Is there some standard way or has anyone written something that allows you to
is there a standard way to encode the user location (country, state/region, town), so
Is there a standard way to access the underlying container of stack , queue

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.