$input = "1,3"; // 輸入的字符串 $numbers = array_map('intval', explode(',', $input)); array_map 函數結合 intval 函數來將每個子字符串轉換為整數