$param = $request->param('', '', 'trim,strip_tags,htmlspecialchars');
// 循环遍历数组中每个IP地址,并将其分割成独立的IP地址
foreach ($param['panel']['business_ip'] as $key => $ipList) {
// 检查IP地址是否包含回车换行符
if (strpos($ipList, "\n") !== false) {
// 将回车换行分隔的IP地址转换为数组形式
$ips = explode("\n", $ipList);
$cleanedIPs = [];
foreach ($ips as $ip) {
$cleanedIPs[] = trim($ip);
}
$param['panel']['business_ip'][$key] = $cleanedIPs;
} else {
// 如果IP地址不包含回车换行符,则按照逗号进行分割
$ips = explode(',', $ipList);
$param['panel']['business_ip'][$key] = $ips;
}
}
// 在转换为JSON之前,移除数组的外层方括号
$param['panel']['business_ip'] = current($param['panel']['business_ip']);
dump($param['panel']['business_ip']);die;