if ($multiselect) { // Check for a separated comma values
if (!
preg_match('/^[^,]+(?:,[^,]+)*$/',
(string) $selected,
$matches)) { throw new InvalidArgumentException(sprintf($errorMessage,
$selected));
} $selectedChoices =
explode(',',
(string) $selected);
} else { $selectedChoices =
[$selected];
} if ($this->
isTrimmable()) { foreach ($selectedChoices as $k =>
$v) { $selectedChoices[$k] =
trim((string) $v);
} } $multiselectChoices =
[];
foreach ($selectedChoices as $value) { $results =
[];
foreach ($choices as $key =>
$choice) { if ($choice ===
$value) { $results[] =
$key;
}