original_string: public function removeOptionByValue($value)
      {
          // walk all options
          $options = $this->options;
  
          // Empty options;
          $this->options = [];
  
          foreach ($options as $option) {
              if ($option instanceof Option) {
                  if ($option->getValue() != $value) {
                      $this->options[] = $option;
                  }
              } else {
                  if ($option instanceof Optgroup) {
                      $subOptions = [];
                      $options2 = $option->getOptions();
                      foreach ($options2 as $option2) {
                          if ($option2->getValue() != $value) {
                              $subOptions[] = $option2;
                          }
                      }
  
                      $option->setOptions($subOptions);
  
                      if (sizeof($subOptions) > 0) {
                          $this->options[] = $option;
                      }
                  }
              }
          }
  
          return $this;
      }
code: public function removeOptionByValue($value)
      {
          // walk all options
          $options = $this->options;
  
          // Empty options;
          $this->options = [];
  
          foreach ($options as $option) {
              if ($option instanceof Option) {
                  if ($option->getValue() != $value) {
                      $this->options[] = $option;
                  }
              } else {
                  if ($option instanceof Optgroup) {
                      $subOptions = [];
                      $options2 = $option->getOptions();
                      foreach ($options2 as $option2) {
                          if ($option2->getValue() != $value) {
                              $subOptions[] = $option2;
                          }
                      }
  
                      $option->setOptions($subOptions);
  
                      if (sizeof($subOptions) > 0) {
                          $this->options[] = $option;
                      }
                  }
              }
          }
  
          return $this;
      }
code_tokens: public function removeOptionByValue ( $ value ) { // walk all options $ options = $ this -> options ; // Empty options; $ this -> options = [ ] ; foreach ( $ options as $ option ) { if ( $ option instanceof Option ) { if ( $ option -> getValue ( ) != $ value ) { $ this -> options [ ] = $ option ; } } else { if ( $ option instanceof Optgroup ) { $ subOptions = [ ] ; $ options2 = $ option -> getOptions ( ) ; foreach ( $ options2 as $ option2 ) { if ( $ option2 -> getValue ( ) != $ value ) { $ subOptions [ ] = $ option2 ; } } $ option -> setOptions ( $ subOptions ) ; if ( sizeof ( $ subOptions ) > 0 ) { $ this -> options [ ] = $ option ; } } } } return $ this ; }
docstring: Remove option by value.
  
  In case that the option was nested in an Optgroup,
  and it was the only option in that optgroup, then the
  optgroup is also removed.
  
  @param $value
  @return SelectField
docstring_tokens: Remove option by value .