public function create($name, $selected='', $attr='')
    {

        // Attributes for select element
        $attrSet = null;
        if (!empty($attr)) {
            if (is_array($attr)) {
                foreach ($attr as $attr_name => $attr_value) {
                    $attrSet .= ' ' .$attr_name. '="' .$attr_value. '"';
                }
            } else {
                $attrSet = ' ' .$attr;
            }
        }

        // start select element
        $listbox = '<select name="' .$name. '"' .$attrSet. '>';

        // Add popular timezones
        $listbox .= '<optgroup label="General">';
        foreach ($this->popularTimezones as $key => $value) {
            $selected_attr = ($selected == $key) ? ' selected="selected"' : '';
            $listbox .= '<option value="' .$key. '"' .$selected_attr. '>' .$value. '</option>';
        }
        $listbox .= '</optgroup>';

        // Add all timezone of continents
        foreach ($this->continents as $continent => $mask) {
            $timezones = DateTimeZone::listIdentifiers($mask);

            // start optgroup tag
            $listbox .= '<optgroup label="' .$continent. '">';

            // create option tags
            foreach ($timezones as $timezone) {
                $selected_attr = ($selected == $timezone) ? ' selected="selected"' : '';

                $listbox .= '<option value="' .$timezone. '"' .$selected_attr. '>';
                $listbox .= $this->formatTimezone($timezone, $continent);
                $listbox .= '</option>';
            }

            // end optgroup tag
            $listbox .= '</optgroup>';
        }

        // end select element
        $listbox .= '</select>';

        return $listbox;
    }
public function create($name, $selected='', $attr='')
    {

        // Attributes for select element
        $attrSet = null;
        if (!empty($attr)) {
            if (is_array($attr)) {
                foreach ($attr as $attr_name => $attr_value) {
                    $attrSet .= ' ' .$attr_name. '="' .$attr_value. '"';
                }
            } else {
                $attrSet = ' ' .$attr;
            }
        }

        // start select element
        $listbox = '<select name="' .$name. '"' .$attrSet. '>';

        // Add popular timezones
        $listbox .= '<optgroup label="General">';
        foreach ($this->popularTimezones as $key => $value) {
            $selected_attr = ($selected == $key) ? ' selected="selected"' : '';
            $listbox .= '<option value="' .$key. '"' .$selected_attr. '>' .$value. '</option>';
        }
        $listbox .= '</optgroup>';

        // Add all timezone of continents
        foreach ($this->continents as $continent => $mask) {
            $timezones = DateTimeZone::listIdentifiers($mask);

            // start optgroup tag
            $listbox .= '<optgroup label="' .$continent. '">';

            // create option tags
            foreach ($timezones as $timezone) {
                $selected_attr = ($selected == $timezone) ? ' selected="selected"' : '';

                $listbox .= '<option value="' .$timezone. '"' .$selected_attr. '>';
                $listbox .= $this->formatTimezone($timezone, $continent);
                $listbox .= '</option>';
            }

            // end optgroup tag
            $listbox .= '</optgroup>';
        }

        // end select element
        $listbox .= '</select>';

        return $listbox;
    }
public function create ( $ name , $ selected = '' , $ attr = '' ) { // Attributes for select element $ attrSet = null ; if ( ! empty ( $ attr ) ) { if ( is_array ( $ attr ) ) { foreach ( $ attr as $ attr_name => $ attr_value ) { $ attrSet .= ' ' . $ attr_name . '="' . $ attr_value . '"' ; } } else { $ attrSet = ' ' . $ attr ; } } // start select element $ listbox = '<select name="' . $ name . '"' . $ attrSet . '>' ; // Add popular timezones $ listbox .= '<optgroup label="General">' ; foreach ( $ this -> popularTimezones as $ key => $ value ) { $ selected_attr = ( $ selected == $ key ) ? ' selected="selected"' : '' ; $ listbox .= '<option value="' . $ key . '"' . $ selected_attr . '>' . $ value . '</option>' ; } $ listbox .= '</optgroup>' ; // Add all timezone of continents foreach ( $ this -> continents as $ continent => $ mask ) { $ timezones = DateTimeZone :: listIdentifiers ( $ mask ) ; // start optgroup tag $ listbox .= '<optgroup label="' . $ continent . '">' ; // create option tags foreach ( $ timezones as $ timezone ) { $ selected_attr = ( $ selected == $ timezone ) ? ' selected="selected"' : '' ; $ listbox .= '<option value="' . $ timezone . '"' . $ selected_attr . '>' ; $ listbox .= $ this -> formatTimezone ( $ timezone , $ continent ) ; $ listbox .= '</option>' ; } // end optgroup tag $ listbox .= '</optgroup>' ; } // end select element $ listbox .= '</select>' ; return $ listbox ; }
Create a GMT timezone select element for form

@param string $name
@param string $selected
@param mixed $attr
@return string
Create a GMT timezone select element for form