$input = "1,3"; // 输入的字符串 $numbers = array_map('intval', explode(',', $input)); array_map 函数结合 intval 函数来将每个子字符串转换为整数