protected static function filterArray (array $values, $filter=null, $args=array(), $doTrim=true)
    {
        if (!$values) {
            return $values;
        }

        if (!$filter) {
            $filter = self::$defaultFilter;
        }

        if (!$args) {
            $args = array ('flags' => self::$defaultFlags);
        }

        foreach ($values as $k=>$v) {
            if (is_array($v)) {
                $values[$k] = self::filterArray ($v, $filter, $args, $doTrim);
            } else {
                $values[$k] = filter_var (self::trim($v, $doTrim), $filter, $args);
            }
        }

        return $values;
    }