<?php

/**
 * @var string|null $class
 * @var string|null $id
 * @var string      $name
 * @var mixed       $selected
 * @var string[]    $options
 */

?>

<select
    class="form-control <?= $class ?? '' ?>"
    name="<?= e($name) ?>"
    id="<?= e($id ?? $name) ?>"
    <?= is_array($selected) ? 'multiple' : '' ?>
>
    <?php foreach ($options as $key => $value) : ?>
        <option value="<?= e((string) $key) ?>" <?= (is_array($selected) ? in_array($key, $selected, false) : (string) $key === (string) $selected) ?  'selected' : '' ?>>
            <?= $value === '' ? '&nbsp;' : e($value) ?>
        </option>
    <?php endforeach ?>
</select>
