Check selected option in list.

@param array $options
@param string $selectedVal
@return array
6375
protected function _checkSelected(array $options, $selectedVal)
    {
        if (!empty($selectedVal) && !Arr::key($selectedVal, $options)) {
            $selectedVal = self::KEY_NO_EXITS_VAL;
            $options = array_merge(array(self::KEY_NO_EXITS_VAL => $this->_translate('No exits')), $options);
        }

        return array($options, $selectedVal);
    }
438208
private static function _intersect($values, $options){

		$filtered = [];

		foreach($values as $option){

			$option = static::_nullValue($option);

			if(in_array($option, $options)){

				$filtered[] = $option;
			}
		}

		return $filtered;
	}
505288
protected function renderSelectCheckbox($items, $selectedValues)
    {
        $parameterArray = [
            'fieldChangeFunc' => [],
            'itemFormElName' => $this->formElementName,
            'itemFormElValue' => $selectedValues,
            'fieldConf' => ['config' => ['items' => $items]],
            'fieldTSConfig' => ['noMatchingValue_label' => '']
        ];

        $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
        $options = [
            'renderType' => 'selectCheckBox', 'table' => 'tx_solr_classes_backend_indexingconfigurationselector',
            'fieldName' => 'additionalFields', 'databaseRow' => [], 'parameterArray' => $parameterArray
        ];
        $options['parameterArray']['fieldConf']['config']['items'] = $items;
        $options['parameterArray']['fieldTSConfig']['noMatchingValue_label'] = '';

        $selectCheckboxResult = $nodeFactory->create($options)->render();
        $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
        $formResultCompiler->mergeResult($selectCheckboxResult);

        $formHtml = isset($selectCheckboxResult['html']) ? $selectCheckboxResult['html'] : '';
        $content = $formResultCompiler->addCssFiles() . $formHtml . $formResultCompiler->printNeededJSFunctions();

        return $content;
    }
1211136
public function select($options = [])
    {
        $useClosure = false;

        if ($options instanceof \Closure) {
            $useClosure = true;
            $options = $options->call($this, $this->row);
        }

        $source = [];

        foreach ($options as $value => $text) {
            $source[] = compact('value', 'text');
        }

        if ($useClosure) {
            $this->addAttributes(['data-source' => json_encode($source)]);
        } else {
            $this->addOptions(compact('source'));
        }
    }
1113706
function _getSelected(select) {
    const arr = [];

    _slice.call(select.options).map((el) => {
        if (el.selected) {
            arr.push(el.value);
        }
    });

    return arr;
}
778582
public function option($text = null, $value = null, $selected = false)
    {
        return Option::create()
            ->text($text)
            ->value($value)
            ->selectedIf($selected);
    }
1135678
public static function toSelect($selectedValue = null, array $options = null)
    {
        $selectOptions = array();
        $selectOptions['class'] = $options['class'] ?? "";
        $selectOptions['id'] = $options['id'] ?? "";
        $selectOptions['name'] = $options['name'] ?? "";

        $reflection = new \ReflectionClass(static::class);

        $html = "<select class='".$selectOptions['class']."' name='".$selectOptions['name']."'>";
        foreach($reflection->getConstants() as $constant => $value)
        {
            $html .= "<option value='{$value}' ".static::isSelectedHTML($selectedValue, $value).">".
                self::WordifyConst($constant)."</option>";
        }
        $html .= "</select>";
        return $html;
    }
918473
public static function multiSelect(string $description, $options, $default = null, bool $allowExit = true): array
    {
        return Checkbox::select($description, $options, $default, $allowExit);
    }
732930
public function setSelected(array $values)
	{
		$this->assertMultiSelect();

		$candidates = array();
		/* @var $candidates SelectOption[] */

		foreach ( $this->getOptions() as $option ) {
			if ( in_array($option->getValue(), $values) ) {
				$candidates[] = $option;
			}
		}

		return $this->selectOptions($candidates);
	}
989701
public static function generateSelectOptionsFromArray( $data, $selected = null ) {

		$options	= "";

		if( isset( $data ) ) {

			if( isset($selected) ) {

				foreach ( $data as $key => $value ) {

					if( $selected === $key ) {

						$options .= "<option value='$key' selected>$value</option>";
					}
					else {
						$options .= "<option value='$key'>$value</option>";
					}
				}
			}
			else {

				foreach ( $data as $key => $value ) {

					$options .= "<option value='$key'>$value</option>";
				}
			}
		}

		return $options;
	}
1227674
public function select($name, $list = [], $selected = null, array $selectAttributes = [], array $optionsAttributes = [], array $optgroupsAttributes = [])
    {
        $selectAttributes = $this->appendClassToOptions('form-control', $selectAttributes);

        if ($this->hasErrors($name)) {
            $selectAttributes = $this->appendClassToOptions('is-invalid', $selectAttributes);
        }

        return parent::select($name, $list, $selected, $selectAttributes, $optionsAttributes, $optgroupsAttributes);
    }
1013167
private function getSelectOptions($options, $selected)
    {
        $select = '';

        foreach ($options as $key => $value) {
            $isSelected = ($selected == $key) ? 'selected="selected"' : '';
            $select .= "<option $isSelected value='".$key."'>".$value.'</option>'.PHP_EOL;
        }

        return $select;
    }
1068155
private static function select_option($label, $value, array $selected) {
        $attributes = array();
        $value = (string)$value;
        if (in_array($value, $selected, true)) {
            $attributes['selected'] = 'selected';
        }
        $attributes['value'] = $value;
        return self::tag('option', $label, $attributes);
    }
1131422
public function check($value, $hashedValue, array $options = [])
    {
        try {
            return $this->hasher->check($value, $hashedValue, $options);
        } catch (RuntimeException $e) {
            return parent::check($value, $hashedValue, $options);
        }
    }
2385
public function check($value, $hashedValue, array $options = array()) {

        return strtoupper($this->make($value)) === strtoupper($hashedValue);
    }
676749
final public function check(array $options) {
        foreach ($options as $property => $value) {
            if ((is_array($value) && !in_array($this->$property, $value)) ||
                    (!is_array($value) && $this->$property !== $value))
                return false;
        }

        return true;
    }
612112
private function getOption($option, array $options)
    {
        return isset($options[$option]) ? $options[$option] : $this->$option;
    }