private function _generate(&$options, &$selected, $level = 0)
    {

        $content = '';

        // character(s) used for indenting levels
        $indent = '&nbsp;&nbsp;';

        // iterate through the available options
        foreach ($options as $value => $caption) {

            // if option has child options
            if (is_array($caption)) {

                // create a dummy option group (for valid HTML/XHTML we are not allowed to create nested option groups
                // and also empty optiongroups are not allowed)
                // BUT because in IE7 the "disabled" attribute is not supported and in all versions of IE these
                // can't be styled, we will remove them from JavaScript
                // having a dummy option in them (the option is disabled and, from CSS, rendered invisible)
                $content .= '
                    <optgroup label="' . str_repeat($indent, $level) . $value . '">
                        <option disabled="disabled" class="dummy"></option>
                    </optgroup>
                ';

                // call the method recursively to generate the output for the children options
                $content .= $this->_generate($caption, $selected, $level + 1);

            // if entry is a standard option
            } else {

                // create the appropriate code
                $content .= '<option value="' . $value . '"' .

                    // if anything was selected
					($selected !== '' && $value !== '' &&

                    	(

                            // and the current option is selected
    						(is_array($selected) && in_array($value, $selected)) ||

                    		(!is_array($selected) && (string)$value === (string)$selected)

                        // set the appropriate attribute
    					) ? ' selected="selected"' : ''

                    ) . '>' .

                // indent appropriately
                str_repeat($indent, $level) . $caption . '</option>';

            }

        }

        // return generated content
        return $content;

    }
private function _generate(&$options, &$selected, $level = 0)
    {

        $content = '';

        // character(s) used for indenting levels
        $indent = '&nbsp;&nbsp;';

        // iterate through the available options
        foreach ($options as $value => $caption) {

            // if option has child options
            if (is_array($caption)) {

                // create a dummy option group (for valid HTML/XHTML we are not allowed to create nested option groups
                // and also empty optiongroups are not allowed)
                // BUT because in IE7 the "disabled" attribute is not supported and in all versions of IE these
                // can't be styled, we will remove them from JavaScript
                // having a dummy option in them (the option is disabled and, from CSS, rendered invisible)
                $content .= '
                    <optgroup label="' . str_repeat($indent, $level) . $value . '">
                        <option disabled="disabled" class="dummy"></option>
                    </optgroup>
                ';

                // call the method recursively to generate the output for the children options
                $content .= $this->_generate($caption, $selected, $level + 1);

            // if entry is a standard option
            } else {

                // create the appropriate code
                $content .= '<option value="' . $value . '"' .

                    // if anything was selected
					($selected !== '' && $value !== '' &&

                    	(

                            // and the current option is selected
    						(is_array($selected) && in_array($value, $selected)) ||

                    		(!is_array($selected) && (string)$value === (string)$selected)

                        // set the appropriate attribute
    					) ? ' selected="selected"' : ''

                    ) . '>' .

                // indent appropriately
                str_repeat($indent, $level) . $caption . '</option>';

            }

        }

        // return generated content
        return $content;

    }
private function _generate ( & $ options , & $ selected , $ level = 0 ) { $ content = '' ; // character(s) used for indenting levels $ indent = '&nbsp;&nbsp;' ; // iterate through the available options foreach ( $ options as $ value => $ caption ) { // if option has child options if ( is_array ( $ caption ) ) { // create a dummy option group (for valid HTML/XHTML we are not allowed to create nested option groups // and also empty optiongroups are not allowed) // BUT because in IE7 the "disabled" attribute is not supported and in all versions of IE these // can't be styled, we will remove them from JavaScript // having a dummy option in them (the option is disabled and, from CSS, rendered invisible) $ content .= '
                    <optgroup label="' . str_repeat ( $ indent , $ level ) . $ value . '">
                        <option disabled="disabled" class="dummy"></option>
                    </optgroup>
                ' ; // call the method recursively to generate the output for the children options $ content .= $ this -> _generate ( $ caption , $ selected , $ level + 1 ) ; // if entry is a standard option } else { // create the appropriate code $ content .= '<option value="' . $ value . '"' . // if anything was selected ( $ selected !== '' && $ value !== '' && ( // and the current option is selected ( is_array ( $ selected ) && in_array ( $ value , $ selected ) ) || ( ! is_array ( $ selected ) && ( string ) $ value === ( string ) $ selected ) // set the appropriate attribute ) ? ' selected="selected"' : '' ) . '>' . // indent appropriately str_repeat ( $ indent , $ level ) . $ caption . '</option>' ; } } // return generated content return $ content ; }
Takes the options array and recursively generates options and optiongroups

@return string  Resulted HTML code

@access private
Takes the options array and recursively generates options and optiongroups