public static function validateString($string, $rule)
    {
        if (!is_array($rule) && ($rule == '' || $rule == null)) {
            return true;
        }

        if (!is_array($string) && ($string == '' || $rule == null)) {
            return true;
        }

        if (!is_array($rule)) {
            $rule = array($rule);
        }

        if (!is_array($string)) {
            $string = array($string);
        }

        foreach ($rule as $r) {
            foreach ($string as $s) {
                if (!preg_match($r, $s)) {
                    return false;
                }
            }
        }
        return true;
    }
public static function validateString($string, $rule)
    {
        if (!is_array($rule) && ($rule == '' || $rule == null)) {
            return true;
        }

        if (!is_array($string) && ($string == '' || $rule == null)) {
            return true;
        }

        if (!is_array($rule)) {
            $rule = array($rule);
        }

        if (!is_array($string)) {
            $string = array($string);
        }

        foreach ($rule as $r) {
            foreach ($string as $s) {
                if (!preg_match($r, $s)) {
                    return false;
                }
            }
        }
        return true;
    }
public static function validateString ( $ string , $ rule ) { if ( ! is_array ( $ rule ) && ( $ rule == '' || $ rule == null ) ) { return true ; } if ( ! is_array ( $ string ) && ( $ string == '' || $ rule == null ) ) { return true ; } if ( ! is_array ( $ rule ) ) { $ rule = array ( $ rule ) ; } if ( ! is_array ( $ string ) ) { $ string = array ( $ string ) ; } foreach ( $ rule as $ r ) { foreach ( $ string as $ s ) { if ( ! preg_match ( $ r , $ s ) ) { return false ; } } } return true ; }
Validate a string against a set of regular expressions.

@param array|string $string
string to operate on
@param array|string $rule
a single rule or array of rules
@return boolean
false if any of the rules in $rule do not match any of the strings in
`$string`, return true otherwise.
Validate a string against a set of regular expressions .