public function build($string = '', $groupSeparator = ',', $viewSeparator = ':')
    {
        // Clear options data
        $this->options = array();

        // Split string into groups and iterate them
        foreach (explode($groupSeparator, $string) as $group) {
            // Split group into view -> value
            $group = explode($viewSeparator, $group);

            // Get value
            $value = $group[0];

            // Get view or set value
            $view = isset($group[1]) ? $group[1] : $group[0];

            // Add option
            $this->options[$value] = $view;
        }

        // Generate options html
        $optionsHTML = '';
        foreach ($this->options as $k => $v) {
            $optionsHTML .= '<option value="' . $k . '"' .
                ($v == $this->value() ? ' selected' : '') . '>' . $v . '</option>';
        }
        // Save select HTML
        $this->optionsHTML = $optionsHTML;

//        // Chaining
//        return $this;
    }
public function build($string = '', $groupSeparator = ',', $viewSeparator = ':')
    {
        // Clear options data
        $this->options = array();

        // Split string into groups and iterate them
        foreach (explode($groupSeparator, $string) as $group) {
            // Split group into view -> value
            $group = explode($viewSeparator, $group);

            // Get value
            $value = $group[0];

            // Get view or set value
            $view = isset($group[1]) ? $group[1] : $group[0];

            // Add option
            $this->options[$value] = $view;
        }

        // Generate options html
        $optionsHTML = '';
        foreach ($this->options as $k => $v) {
            $optionsHTML .= '<option value="' . $k . '"' .
                ($v == $this->value() ? ' selected' : '') . '>' . $v . '</option>';
        }
        // Save select HTML
        $this->optionsHTML = $optionsHTML;

//        // Chaining
//        return $this;
    }
public function build ( $ string = '' , $ groupSeparator = ',' , $ viewSeparator = ':' ) { // Clear options data $ this -> options = array ( ) ; // Split string into groups and iterate them foreach ( explode ( $ groupSeparator , $ string ) as $ group ) { // Split group into view -> value $ group = explode ( $ viewSeparator , $ group ) ; // Get value $ value = $ group [ 0 ] ; // Get view or set value $ view = isset ( $ group [ 1 ] ) ? $ group [ 1 ] : $ group [ 0 ] ; // Add option $ this -> options [ $ value ] = $ view ; } // Generate options html $ optionsHTML = '' ; foreach ( $ this -> options as $ k => $ v ) { $ optionsHTML .= '<option value="' . $ k . '"' . ( $ v == $ this -> value ( ) ? ' selected' : '' ) . '>' . $ v . '</option>' ; } // Save select HTML $ this -> optionsHTML = $ optionsHTML ; //        // Chaining //        return $this; }
Parse string into select options

@param string $string 			Input string
@param string $groupSeparator 	Separator string for groups
@param string $viewSeparator	Separator string for view/value
@return Select Chaining
Parse string into select options