<?php

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

?>

<select
    class="form-select <?= $class ?? '' ?>"
    name="<?= e($name) ?>"
    id="<?= e($id ?? $name) ?>"
    <?= is_array($selected) ? 'multiple="multiple"' : '' ?>
    aria-label="<?= e($aria_label ?? '') ?>"

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