public static function filter_data(&$data, $filterArr, $method = null, $add = false)
    {
        if ($method === null) {
            $method = 'keep';
        }

        foreach ($data as $k => $v) {
            if (($method == 'remove' && in_array($k, $filterArr))
             || ($method == 'keep' && !in_array($k, $filterArr))
            ) {
                if (is_array($data)) {
                    unset($data[$k]);
                } elseif (is_object($data)) {
                    unset($data->$k);
                }
            }
        }

        if (!empty($add)) {
            $data = self::merge_data($data, $add);
        }

        return $data;
    }