From ef312fc70bbb1ecb6ae1045a5da3e36d8ab41d8a Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Wed, 9 May 2007 13:03:59 +0000 Subject: [PATCH] PMA_isValid(): added ability to check $var against array of valid values --- libraries/core.lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/core.lib.php b/libraries/core.lib.php index c6a1c2cd1..78072c47a 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -32,7 +32,7 @@ * @see PMA_isValid() * @param mixed $var param to check * @param mixed $default default value - * @param string $type var type to check against $var + * @param mixed $type var type or array of values to check against $var * @return mixed $var or $default */ function PMA_ifSetOr(&$var, $default = null, $type = 'similar') @@ -81,11 +81,13 @@ function PMA_ifSetOr(&$var, $default = null, $type = 'similar') * @todo add some more var types like hex, bin, ...? * @uses is_scalar() * @uses is_numeric() + * @uses is_array() + * @uses in_array() * @uses gettype() * @uses strtolower() * @see http://php.net/gettype * @param mixed $var variable to check - * @param string $type var type to check against $var + * @param mixed $type var type or array of valid values to check against $var * @param mixed $compare var to compare with $var * @return boolean whether valid or not */ @@ -101,6 +103,10 @@ function PMA_isValid(&$var, $type = 'length', $compare = null) return true; } + if (is_array($type)) { + return in_array($var, $type); + } + // allow some aliaes of var types $type = strtolower($type); switch ($type) {