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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:59:47+00:00 2026-06-16T07:59:47+00:00

I want get (handling) values input and checkboxes as following example, without change in

  • 0

I want get (handling) values input and checkboxes as following example, without change in name element in checkboxes, I tried as following but this don’t work:

DEMO: http://codepad.viper-7.com/4ldRKV

<?php
if($_POST){
    //foreach ($_POST['cDA'] as $idx => $value) {
        foreach ($_POST as $idx => $value) {
            echo '<pre>';
            print_r($_POST);
        }
    //}
}
?>
<form action="#" method="post">
    <input type="text" name="cDI[]" value="F1">
        <input type="checkbox" name="cDA[0][]" value="11" checked>
        <input type="checkbox" name="cDA[0][]" value="11" checked>
        <input type="checkbox" name="cDC[1][]" value="22" checked>
        <input type="checkbox" name="cDC[1][]" value="22" checked>
    </br>
    <input type="text" name="cDI[]" value="F2">
        <input type="checkbox" name="cDA[0][]" value="33" checked>
        <input type="checkbox" name="cDA[0][]" value="33" checked>
        <input type="checkbox" name="cDC[][]" value="44" checked>
        <input type="checkbox" name="cDC[][]" value="44" checked>
    </br>
    <input type="text" name="cDI[]" value="F3">
        <input type="checkbox" name="cDA[0][]" value="55" checked>
        <input type="checkbox" name="cDA[0][]" value="55" checked>
        <input type="checkbox" name="cDC[][]" value="66" checked>
        <input type="checkbox" name="cDC[][]" value="66" checked>
    </br>
<input type="submit" value="Submit">
</form>

I want in output as: ( how should change html and php to getting following result? )

Array
(
    [cDI] => Array
        (
            [0] => F1
            [1] => F2
            [2] => F3
        )
    [cDA] => Array
        (
            [0] => Array
                (
                    [0] => 11
                    [1] => 11                    
                )
            [1] => Array
                (
                    [0] => 33
                    [1] => 33                    
                )
            [2] => Array
                (
                    [0] => 55
                    [1] => 55                    
                )

        )
    [cDC] => Array
        (
            [0] => Array
                (
                    [0] => 22
                    [1] => 22                    
                )
            [1] => Array
                (
                    [0] => 44
                    [1] => 44                    
                )
            [2] => Array
                (
                    [0] => 66
                    [1] => 66                    
                )

        )

)
  • 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-16T07:59:48+00:00Added an answer on June 16, 2026 at 7:59 am

    If you use cDA[0][] as the name of a collection of input boxes, it will turn $_POST['cDA'] into this:

    array(
        0 => array(
            0 => 11,
            1 => 11,
            2 => 33,
            3 => 33,
            4 => 55,
            5 => 55,
        ),
    );
    

    Using cDC[][] as the names of your input boxes, you will end up with this array in $_POST['cDC']:

    array(
        0 => array(
            0 => 11,
        ),
        0 => array(
            0 => 11,
        ),
        0 => array(
            0 => 33,
        ),
        0 => array(
            0 => 33,
        ),
        0 => array(
            0 => 55,
        ),
        0 => array(
            0 => 55,
        ),
    );
    

    To make them group properly you have to set the value between the first square brackets explicitly:

    cDA[0][]
    cDA[0][]
    cDC[0][]
    cDC[0][]
    
    cDA[1][]
    cDA[1][]
    cDC[1][]
    cDC[1][]
    
    cDA[2][]
    cDA[2][]
    cDC[2][]
    cDC[2][]
    

    Demo

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

Sidebar

Related Questions

I want to get 100 and example from this string ?connect:100/username:example/ I searched in
This is how I'm handling values in a Ruby hash to get an alpha-numeric
Why would I want to get out of an Error Handler (after handling) with
I want get the time used for a case so I can create an
I want get all of the Geom objects that are related to a certain
I want get as much as possible from Redis + Hiredis + libevent. I'm
What I want: get a xml from the AppData to use What I code
Basically I want get data I already have accessed from javascript and passing it
I just want get a 2 dimension array of List in c#. In my
i want query a file xml with linq, i want get all descendat of

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.