I am trying to check that all query requests from a form is filled and not hindered before proceeding with further actions.
I have a code that works already, but i would like to make it an array in other to shorten my code.
My form queries are a,b,c
Below is my current code:
if ( isset($_GET) && !isset($_GET['a']) || !isset($_GET['b']) || !isset($_GET['c']) )
{ //Reject call
}else{
//Process call
}
I wish to shorten this code with an array, here is my current code but this isn't working.
$supportedrequests = array('a','b','c')
if (isset($_GET) && !isset($_GET[(in_array($supportedrequests))]) ) {
{ //Reject call
}else{
//Process call
}
Any help will be appreciated.
UPDATE
This question is not a duplicate of Using if(!empty) with multiple variables not in an array because it is specifically based on checking isset($_GET) query itself if it exists, and aside that, no answer was fully rendered for the said topic in the stated link.
isset($_GET)check is redundant, you can be sure that it will be setif ( isset($_GET) && !isset($_GET['a']) || !isset($_GET['b']) || !isset($_GET['c']) )- That whole statement doesn't make much sense here, as noted earlier by Artem. You might want to post the form for this as you say you are using one. At best, you can use a ternary operator, or a switch case.