NYCPHP Meetup

NYPHP.org

[nycphp-talk] Manipulating $_REQUEST Directly

Peter Sawczynec ps at sun-code.com
Mon Jul 16 22:26:48 EDT 2007


I have inherited some old legacy code that down and dirty uses $_REQUEST
to universally grab all varibales from combined GET and/or POST form
submissions.

So I want to be equally blunt and directly chop up and massage $_REQUEST
before any code handles it.

I want to have an array of acceptable "white list" $_REQUEST variable
names I am looking for, allow those to remain in the $_REQUEST array,
but I want all other $_REQUEST variables removed/destroyed out of
$_REQUEST.

Then simply allow the the remaining "white list" $_REQUEST to flow into
the code.

So, for example I want to do something really short like so:

$whitelist_var_names = array('name', 'address', 'phone');

$_REQUEST = array_intersect_assoc($whitelist_var_names, $_REQUEST);


Can anyone give me a really short code burst, or isolate the proper
array function(s) that will do this for me? 

Thank you one and all, if you can help.


Warmest regards, 
 
Peter Sawczynec 
Technology Dir.
Sun-code.com 
Web related services 
646.316.3678 
ps at sun-code.com






More information about the talk mailing list