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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:33:21+00:00 2026-06-11T14:33:21+00:00

I have a form with inputs that can be duplicated with jQuery. The inputs

  • 0

I have a form with inputs that can be duplicated with jQuery. The inputs are like this

<select name='user_id[]'>
    <option value=''>Select a user</option>
    <option value='1'>Alice</option>
    <option value='2'>Bob</option>
</select>
<input type="text" id="drinks1" name="drinks[]" />
<input type="text" id="drinks2" name="drinks[]" />
<input type="text" id="food1" name="food[]" />
<input type="text" id="food2" name="food[]" />

So in my processing script I have the arrays $_POST['userid'], $_POST['drinks'] and $_POST['food']

How can I check if these are empty? The empty() function doesnt work because they look like this when I print them Array ( [0] => ) which appears to be non-empty.

  • 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-11T14:33:22+00:00Added an answer on June 11, 2026 at 2:33 pm

    Simply loop through the array to check if any field is empty:

    foreach($_POST['userid'] as $key=>$value) if(empty($value)) echo "empty";
    

    You can do the same with all your arrays.

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

Sidebar

Related Questions

I have a form that takes the following inputs: Name: IBM Surface(in m^2): 9
I have a login form that has Username and password as inputs from user
I have a form that can be dynamically duplicated (with JS) so that the
I have a form that inputs url dynamically, the user may input www.stack.com or
I have a dynamic form that users can add/delete sets of input fields. I
So i have a simple form that takes a few inputs (two text and
I have a form that uses jquery to generate rows of input fields these
So I have a form that accepts some input from a user that may
I have a complex form that has a static section and one that can
I need to make a form that can display certain form inputs when another

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.