One sample loop to get both the array keys & values:
foreach( $_POST as $key => $value )
{
isvalid( $key, $value );
}
... so you need to change your isvalid()
function to accept two parameters if you need to get the field1
, field2
, etc.
EDITED
$errors = array();
foreach( $_POST as $key => $value )
if ( empty( $value ) ) $errors[] = $key;
if ( !empty( $errors ) )
echo 'You have errors on: ' . print_r( $errors, true ) . '
';
... you can cancel the submit if $errors
is not empty.