$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
You can store all the field names that have to be tested in an array:
and then loop over it:
Side note: You don’t need
$form = array();.