Hey there. I am writing some PHP that needs to check to see if a inputted value fits in with a whole bunch of options. What’s the best way to hold all options to check against? I know that an array would work, but is there anything more efficent for this type of operation?
Share
Checking if the input is a member of an array is actually a pretty safe and efficient way of securing it. For more complex checks, you may want to consider regular expressions with preg_match. However, regular expressions can easily become complicated. Also, one word of advice: Until you’ve modified the php interpreter, do not worry about of the efficiency of php commands except for loops and network code.
In many cases, you can actually accept anything and then encode it.