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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:09:58+00:00 2026-06-14T16:09:58+00:00

I have a project where I create hidden input values with jQuery. These represent

  • 0

I have a project where I create hidden input values with jQuery. These represent groups and members so I have one array for the groups themselves and arrays with the members of each groups.

For example after a few creations the code in the form includes

<input type="hidden" name="groups['group_2']" value="0">
<input type="hidden" name="groups['group_1']" value="0">
<input type="hidden" class="mem_id_holder" name="group_1[]" value="FWNGVISkjW">
<input type="hidden" class="mem_id_holder" name="group_1[]" value="G0t9E3C0yG">
<input type="hidden" class="mem_id_holder" name="group_2[]" value="NT-JEDVCS9">

for an example of 2 groups with 2 members in group_1 and 1 member in group_2.

Now, after the submit my code to iterate through the values I use this code:

if ($groups_no && isset($_POST['groups']) && !empty($_POST['groups'])){
    $groups = $_POST['groups'];
    foreach ($groups as $key => $val){
        if (isset($_POST[$key]) && !empty($_POST[$key])){
            $group_members = $_POST[$key];      
            foreach ($group_members as $member_key => $member_val){
                echo 'Actions to be done here!';
            }
        }
    }
}

The problem I have is that I get the following warning and the program fails:

Notice: Undefined index: 'group_1' in C:\ ... .php on line 31
Warning: Invalid argument supplied for foreach() ...
Notice: Undefined index: 'group_2' in C:\ ... .php on line 31
Warning: Invalid argument supplied for foreach() ...

When I use $_POST['group_1'] everything works fine but since I do not know how many and which groups I will have to insert I need the variable. I have tried some different things suggested via some Google results but nothing worked.

Any ideas? Is $_POST even capable of having variables as indexes? Also if it isn’t, is there any other workaround?

  • 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-06-14T16:09:59+00:00Added an answer on June 14, 2026 at 4:09 pm

    In your HTML, don’t put quotes around the array indexes.

    <input type="hidden" name="groups[group_2]" value="0">
    <input type="hidden" name="groups[group_1]" value="0">
    <input type="hidden" class="mem_id_holder" name="group_1[]" value="FWNGVISkjW">
    <input type="hidden" class="mem_id_holder" name="group_1[]" value="G0t9E3C0yG">
    <input type="hidden" class="mem_id_holder" name="group_2[]" value="NT-JEDVCS9">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project to create a program, which prevents the user from escaping
I have a project where I create WiX (Windows Installer for XML) files, when
So for my programming class we have had a project to create a virtual
I have a project using DynamicJasper to create reports. It works fine so far,
I have a Create View page in my MVC3 project to create instances of
I have Maven project with Hibernate and Spring framework. I want Hibernate to create
I have created my database, and used cake bake my_project to create my project,
For a project I have to create a music visualizer in java (I've decided
For a project we have a requirement to create an interfacedefinition that will return
I have a maven project and I'd like to create a distribution of it

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.