2012-04-24 35 views
0

所有國家的電話號碼有什麼辦法來驗證與PHP的所有國家的電話號碼如何驗證用PHP

+2

給定一個合適的數據集進行比較,是 – Phil 2012-04-24 07:13:44

回答

1

可以使用的preg_match實現這一點,我不認爲任何自動驗證存在

通過使用用於存儲格式,然後檢查那些與輸入PHONENUMBER數據庫

int preg_match (string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]]) 

例如,

<?php 
// The "i" after the pattern delimiter indicates a case-insensitive search 
if (preg_match("/php/i", "PHP is the web scripting language of choice.")) { 
    echo "A match was found."; 
} else { 
    echo "A match was not found."; 
} 
?> 

看到這個 http://php.net/manual/en/function.preg-match.php

0

大約需要國家的電話號碼的信息從起始碼:
http://www.international-dialing-codes.net/
插入到數據庫,創建陣列,使while循環它會從數據庫獲取信息, 然後創建的foreach .. 類似的東西..