src/MVC/View.php
function select(array $options_data, $default_value = null, array $select_params = array(), array $user_option_params = array())
    {
        $content = '';
        if (is_array($default_value)) {
            $default_value = array_flip($default_value);
        } else {
            $default_value = array($default_value => true);
        }

        foreach ($options_data as $value => $option) {
            $option_params = array();
            if (!empty($user_option_params)) {
                $option_params = $user_option_params;
            }

            if (is_array($option)) {
                $opt_content = '';
                foreach ($option as $opt_value => $opt_option) {
                    unset($option_params['selected']);
                    $option_params['value'] = $opt_value;
                    $option_params['@content'] = $opt_option;
                    if (isset($default_value[$opt_value])) {
                        $option_params['selected'] = true;
                    }

                    $opt_content .= self::htmlTag('option', $option_params);
                }

                $opt_params['label'] = $value;
                $opt_params['@content'] = $opt_content;
                $content .= self::htmlTag('optgroup', $opt_params);
            } else {
                $option_params['value'] = $value;
                $option_params['@content'] = $option;
                if (isset($default_value[$value])) {
                    $option_params['selected'] = true;
                }

                $content .= self::htmlTag('option', $option_params);
            }
        }

        $select_params['@content'] = $content;
        return $this->wrapContent(self::htmlTag('select', $select_params), false);
    }
function select(array $options_data, $default_value = null, array $select_params = array(), array $user_option_params = array())
    {
        $content = '';
        if (is_array($default_value)) {
            $default_value = array_flip($default_value);
        } else {
            $default_value = array($default_value => true);
        }

        foreach ($options_data as $value => $option) {
            $option_params = array();
            if (!empty($user_option_params)) {
                $option_params = $user_option_params;
            }

            if (is_array($option)) {
                $opt_content = '';
                foreach ($option as $opt_value => $opt_option) {
                    unset($option_params['selected']);
                    $option_params['value'] = $opt_value;
                    $option_params['@content'] = $opt_option;
                    if (isset($default_value[$opt_value])) {
                        $option_params['selected'] = true;
                    }

                    $opt_content .= self::htmlTag('option', $option_params);
                }

                $opt_params['label'] = $value;
                $opt_params['@content'] = $opt_content;
                $content .= self::htmlTag('optgroup', $opt_params);
            } else {
                $option_params['value'] = $value;
                $option_params['@content'] = $option;
                if (isset($default_value[$value])) {
                    $option_params['selected'] = true;
                }

                $content .= self::htmlTag('option', $option_params);
            }
        }

        $select_params['@content'] = $content;
        return $this->wrapContent(self::htmlTag('select', $select_params), false);
    }
输出select

@param array $options_data 二维数组时, 生成optgroup
@param int|string|array $default_value
@param array $select_params
@param array $user_option_params
@return mixed