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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:57:38+00:00 2026-05-22T21:57:38+00:00

$form = array(); $form = $_POST[‘data’]; function livre($form) { if (empty($form[radios]) || empty($form[age]) ||

  • 0
$form = array();
$form = $_POST['data'];

    function livre($form) {
        if (empty($form["radios"]) || empty($form["age"]) 
        || empty($form["gender"]) || empty($form["civil"]) 
        || empty($form["formation_area"]) || empty($form["scholarithy"])
        || empty($form["professional_activity"]) || empty($form["city_work"])
        || empty($form["contract_job"]) || empty($form["salary"])){
            echo ("empty");
        }
        else
        echo ("not empty");

    }

        livre($form_data_array);

the first question is: Is possible reduce the number of empty to one, like empty($form) || ($form1)

the second is: how i can reduce the number of lines, i feel this scheme that i use is not the best way. I can’t simple verify if the array is empty because only some indexes can be empty.

thanks

  • 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-22T21:57:39+00:00Added an answer on May 22, 2026 at 9:57 pm

    You can store all the field names that have to be tested in an array:

    $fields = array('radios', 'age', ...);
    

    and then loop over it:

    foreach($fields as $field) {
       if(empty($form[$field])) {
           echo 'empty';
           break;
       }
    }
    

    Side note: You don’t need $form = array();.

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

Sidebar

Related Questions

Find below my form and the action page it submits to. The _POST array
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have an associative array in the form key => value where key is
I have an array in the form of ' int[][] ' that represents the
I need the form that will edit the array of entities and their related
I have declared an array in the form: var refs = { 'EE810': Presence
I have an array of JButtons which form a keypad interface. After six numbers
I have an array of integers in string form: var arr = new string[]
I can create an array of buttons in Windows Form but how can i
I am loading a file into a array in binary form this seems to

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.