regex - simple regular expression in php to check for possible values for a variable -


there are few finite values variable $_get['action'] can take, either "new", "edit", or "delete".

i want sanitize input security , make sure variable 1 of above values, how can using regular expressions?

i don't want go , say:

if(isset($_get['action']) && ($_get['action'] == 'new' || $_get['action'] == 'edit' || $_get['action'] == 'delete')) 

i not use regex this. use in_array() check value against white list:

if(!in_array($_get, array("new", "edit", "delete"), true)) {     die('error!'); } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -