我試圖從服務器端處理來檢查字符串格式正確與否例如PHP驗證逗號serprated 10個位數的電話號碼
$string = "9000010000,9100011000,9000020000 // Its correct pattern
$string = "9000010000,9100011000,9000020000, // Its WRONG Reason comma in last place
$string = ",9000010000,9100011000,9000020000, // Its WRONG Reason comma in first place
$string = ",9000010000,9100011000,,9000020000, // Its WRONG Reason ,,
$string = "9000010000,9100011,9000020000, // Its WRONG because Middle no. is not 10 digit
我已經沒有使用此代碼
通過JavaScript客戶端驗證var listIsOk=/^(\d{10},)*\d{10}$/.test(contact_list);
if(listIsOk==true){
alert("success"
}
else {
alert("string is wrong")
}
我想知道我怎麼能在PHP實現這種預先感謝您
由於其工作真棒:) – Allex
沒問題。無論如何,看起來你的模式是正確的,你只需要PHP函數。 –