The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
How do I easily check if one variable equals ANY of a list of values?
In my Custom HTTP Error Pages hack, I use a variable $e. The value of $e comes from the URL, as in http://www.yoursite.com/forums/httperror.php?e=404.
I have a check in the script that checks for if $e has a value or not, and if not, it's set to 404 (because the 404 page is the accepted generic page to use if the exact error cannot be determined or does not wish to be revealed). But I'd like to add another check that makes sure $e is set to an acceptable value, and if not, set it to 404. Is there an easy way to check if $e is set to ANY item in a list like 400, 401, 403, 404, 405, etc.? |
#2
|
|||
|
|||
Quote:
PHP Code:
or you can store the Value in an array and chek if the value in that array if not set it to 404 use the function inarray to check for it PHP Code:
|
#3
|
||||
|
||||
Using the last example, the !inarray bit, if I have an existing IF statement to check the value of $e, can I combine that with this?
This is what I use already: Code:
if ($e == '' OR !$e) { $e = '404'; } Code:
if ($e == '' OR !$e OR !inarray($e,$error)) |
#4
|
|||
|
|||
Quote:
PHP Code:
PHP Code:
|
#5
|
||||
|
||||
I have tried that now, and got the error message...
Quote:
|
#6
|
|||
|
|||
Quote:
in_array my mistake |
#7
|
||||
|
||||
Thanks!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|