-4

I have more than 30 fields in a form, and can't believe that I must write an array to check if any of them is empty (likehere)

I need something like js

$_POST[].each function{
 if this is empty...
}

and hope that 'php' as so glorified language has something like this or similar.

Community
  • 1
  • 1
qadenza
  • 8,611
  • 18
  • 61
  • 108

1 Answers1

1

Try this:

foreach($_POST as $post)
{
    if( !empty($post) )
    {
        // your code here
    }
}
RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
Mayank Pandeyz
  • 24,624
  • 3
  • 35
  • 55