Say these are your incoming GET vars.
$_GET['id'] = 23 ;
$_GET['titles'] = array("title one", "title two") ;
$_GET['sql'] = array("bad stuff1", "badstuff2") ;
$preserve=array('id', 'titles' );
$_GET = array_intersect_key($_GET, array_flip($preserve));
if( $a = array_diff( $preserve, array_keys($_GET) ) )
exit('Did not get: ' . print_r( $a , 1 ));
var_dump( $_GET );
The output silently wipes out those vars not expected.
Output;
array
'id' => int 23
'titles' =>
array
0 => string 'title one' (length=9)
1 => string 'title two' (length=9)
if you change the $preserve array to include a new var, one which will be missing from the incoming GET vars:
$preserve=array('id', 'titles' , 'color');
Then the operation stops and output is;
Did not get: Array ( [2] => color )
Which seems handy,
To be honest I am not entirely sure where I am going with this idea, I just wanted a line or 2 to help me debug - and a bonus maybe leave something in place to wipe out any unwanted attention.
But my brain is telling me I could be doing something like:
if( $DEBUG ){
include 'checkVars.php' ;
checkvars( $_GET, array('id', 'title') ) ;
}
Edit:
Ah, Anthony, hadnt seen your post … leaving this all the same.