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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:44:17+00:00 2026-05-24T02:44:17+00:00

I am trying to pass an array of values through a form submission. As

  • 0

I am trying to pass an array of values through a form submission. As an example:

example.com?value1=178&value2=345&value3=2356

The easy solution would be for me to do the following to get the values on the new page:

$value1=$_GET['value1'];
$value2=$_GET['value2'];
$value3=$_GET['value3'];

The difficulty that I am having is that the variable after the word ‘value’ passed through the form will change with each submission. So I have amended the code to pass as:

example.com?value14=178&variable=14&value23=345&variable=23&value63=2356&variable=63

As you can see here, I have now passed the variable that comes in from of the value as a GET parameter. My attempt then GET these values to display individually on the submitted page is as follows:

$variable=$_GET['variable'];    
$value=$_GET['value'.$variable];

echo $value . '<br>';

This code almost works. I am able to get the last array which is passed through to display. How can I fix this code to get all of the passed values to display on the submitted page?

  • 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-24T02:44:18+00:00Added an answer on May 24, 2026 at 2:44 am

    Use PHP’s array notation for form fields:

    val[]=178&val[]=14&val[]=345&etc...
    

    This will cause $_GET[‘val’] to be an array:

    $_GET = array(
       'val' => array(178, 14, 345, etc...)
    )
    

    If you can’t rearrange the URL like that, you can try using preg_grep:

    $matches = preg_grep('/^variable\d+$/', array_keys($_GET));
    

    which’ll return :

    $matches= array('variable1', 'variable2', 'variable3', etc...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem when trying to pass an array back to a COM
I am trying to seperate values in an array so i can pass them
I'm trying to pass through POST an array of checkboxes but this time it's
I am trying to pass an array of values into an array of a
I am trying to pass several values through an IMultiValueConverter to a command (as
I am trying to pass array parameter to SQL commnd in C# like below,
I'm trying to pass a byte array from inside my rails app into another
I'm trying to pass 3 parameter to a script, where the 3rd parameter $_GET['value3']
basically I'm trying to pass a variable that is defined in a JSON array
I'm trying to loop through an array fSel.sI, and based on the data inside,

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.