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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:43:09+00:00 2026-05-24T23:43:09+00:00

How to set a = 0 value for each checkbox unchecked Error: Warning: array_combine()

  • 0

How to set a = 0 value for each checkbox unchecked

Error:

Warning: array_combine() [function.array-combine]: Both parameters should have an equal number of elements in

PHP:


$combined = array_combine($_POST['name'], $_POST['day']);

foreach($combined as $name => $value) {
     echo $name.' => '.$value;
}

HTML:

  <form method="post" action="result.php">
  <p>
        <input type="text" name="name[]" value="seth" />
        <input type="checkbox" name="day[]" value="7" />
  </p>

  <p>
        <input type="text" name="name[]" value="jack" />
        <input type="checkbox" name="day[]" value="4" />
  </p>

  <p>
        <input type="text" name="name[]" value="david" />
        <input type="checkbox" name="day[]" value="3" />
  </p>

 </form>

PS:
I won’t use:

        <select name="day[]" size="1">
           <option value="0"> Non </option>
           <option value="1"> Yes </option>
        </select>
  • 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-24T23:43:09+00:00Added an answer on May 24, 2026 at 11:43 pm

    Here you go. Hope this works for you. It’s a bit more work then what you were hoping for probably.

    result.php

    <?PHP
    
    $days = array();
    $namecount = count($_POST['name']);
    for($i = 0; $i < $namecount; $i++){
        $days[$i] = isset($_POST['day'][$i]) ? $_POST['day'][$i] : 0;
    }
    
    $arr = array_combine($_POST['name'], $days);
    print_r($arr);
    
    ?>
    

    form.html

    <form method="post" action="result.php">
        <p>
            <input type="text" name="name[]" value="seth" />
            <input type="checkbox" name="day[0]" value="7" />
        </p>
    
        <p>
            <input type="text" name="name[]" value="jack" />
            <input type="checkbox" name="day[1]" value="4" />
        </p>
    
        <p>
            <input type="text" name="name[]" value="david" />
            <input type="checkbox" name="day[2]" value="3" />
        </p>
        <input type='submit' value='Submit' />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of values, each value has a possible group. The value
I'm creating a set of enum values, but I need each enum value to
I have a form action that needs to have its value set from a
I have a repeater, in each ItemTemplate of the repeater is an asp:checkbox with
I have a table set out like: <table id=myTable> <thead> <tr> <td><input type=checkbox id=selectall
I have several forms, all which require a checkbox for each province/state. Therefore, I've
How can i set value(in code behind) for an element declared in the xslt
I am attempting to set a value in a textarea field using jquery with
I'm having trouble trying to set the value of a property after i cast
I wonder if there is a way to set the value of #define in

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.