-
Notifications
You must be signed in to change notification settings - Fork 844
Open
Description
$allow 参数只会过滤第一个值,第二个就不生效了
这是解决后的方法
`
function str2arr(string $text, string $separ = ',', ?array $allow = null): array
{
$items = [];
foreach (explode($separ, trim($text, $separ)) as $item) {
$trimmedItem = trim($item);
if ($trimmedItem !== '' && (is_null($allow) || in_array($trimmedItem, $allow))) {
$items[] = $trimmedItem;
}
}
return $items;
}
`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels