I wonder if there any better ideas to solve the problem below,
I have a form with a number of input fields, such as,
You can create a small function that can do this job for you simply.
function sc_post_isset(...$args) {
$exists = true;
foreach($args as $arg) {
if ( !isset($_POST[$arg]) || empty($_POST[$arg]) ) {
$exists = false;
}
}
return $exists;
}
Use,
if(sc_post_isset('key')) {
// it exists.
}
OR
if(sc_post_isset('key1', 'key2', 'key3')) {
// it exists.
}
It just simply check if all the provided keys exist within $_POST and not empty