src/TreeGroup.php
public function toSelect(array &$optgroups=[], $level=1, $root=true)
  {
    $options = [];
    foreach($this->items as $item){
      $options[] = $item->toSelect();
    }
    
    if ( $root === true ){
      $text = $this->text;
    }
    else {
      $text = '|'.str_repeat('-', $level).' '.$this->text;
    }
    
    $optgroups[] = [
      'text' => $text,
      'options' => $options,
    ];
    
    foreach($this->groups as $group){
      $group->toSelect($optgroups, $level+1, false);
    }
  }
public function toSelect(array &$optgroups=[], $level=1, $root=true)
  {
    $options = [];
    foreach($this->items as $item){
      $options[] = $item->toSelect();
    }
    
    if ( $root === true ){
      $text = $this->text;
    }
    else {
      $text = '|'.str_repeat('-', $level).' '.$this->text;
    }
    
    $optgroups[] = [
      'text' => $text,
      'options' => $options,
    ];
    
    foreach($this->groups as $group){
      $group->toSelect($optgroups, $level+1, false);
    }
  }
public function toSelect ( array & $ optgroups = [ ] , $ level = 1 , $ root = true ) { $ options = [ ] ; foreach ( $ this -> items as $ item ) { $ options [ ] = $ item -> toSelect ( ) ; } if ( $ root === true ) { $ text = $ this -> text ; } else { $ text = '|' . str_repeat ( '-' , $ level ) . ' ' . $ this -> text ; } $ optgroups [ ] = [ 'text' => $ text , 'options' => $ options , ] ; foreach ( $ this -> groups as $ group ) { $ group -> toSelect ( $ optgroups , $ level + 1 , false ) ; } }
Export group infos for an optgrouped select

@return   void
Export group infos for an optgrouped select