// your incoming GET vars
$_GET = array(
'a'=>1
, 'b'=>2
, 'c' => ''
, 'd'=>0);
// vs what you are expecting, as keys (a so called 'white-list')
$expected = array('a','b','e');
// a) check rather dumbly which are "empty" - even if not on white-list
foreach( $_GET as $k=>$v){
if(empty($v)) echo "$k is empty <br />";
}
// b) check for keys which should not be there (not on 'white-list')
$bad_key = array_diff( array_keys($_GET), $expected );
if($bad_key) echo 'Unexpected key found ' . print_r($bad_key, 1),'<br />' ;
// c) check for keys which should be there but are not set (missing from white-list)
$missing_key = array_diff( $expected, array_keys($_GET) );
if($missing_key) echo 'Missing key detected:',print_r($missing_key, 1), '<br />';
Outputs:
c is empty
d is empty
Unexpected key found Array ( [2] => c [3] => d )
Missing key detected :Array ( [2] => e )
I’m not saying you need all/any of this by any means, as it not exactly clear what you are after - its just that I ended up writing something like b) yesterday, and I wondered maybe there is a better way of doing it?
if( isset($title) && isset($first) && isset($first) ... etc ){
echo 'all were set, but might be empty**';
}else{
echo 'well at least one was not set, but which one?';
}
if affid is set, this is TRUE. Which… isnt what you want. Because you’re looking for something that is missing. You’re looking for if affid is NOT set… (Hint: NOT.)