i have this code. Basically identifies if any position of array is empty or have an input equal a zero.
$fields = array("first", "second", "third");
function check($fields, $form) {
foreach($fields as $field) {
if(empty($form[$field]) || $form[$field] === 0) {
echo 'empty';
return false;
break;
}
}
}
My doubt now, is , how i can do an echo for example to show the second position is empty?
with an if? if ($form[$field][second]) ? i don’t know if this is correct, or exists a better option
thanks
if
$fieldis what you want toechothen just prepend it to ‘is empty’:if you need the index value:
eventually if the aim is retrieve the empty position (if
checkreturns-1then there are no empty positions):