if ($_post) { $phone = (Isset ($_post["Phone"])? $_post["Phone"]:d ie ("please return"); echo "You inquire: $phone, Information:". Getphone ($phone); function Getphone ($phone) { $dbpath = "datas/"; $len =strlen ($phone); if ($len!=11) { Return "mobile phone number only support 11-bit"; } $par = "[0-9]"; for ($i =0; $i < $len; $i + +) { if (!ereg ($par, substr ($phone, $i, 1)) { Return "mobile phone number can only be a number"; } } $sunum =scandir ($dbpath); Get supported phone number prefix Array_splice ($sunum, 0, 1); Cancel the current directory Array_splice ($sunum, 0, 1); Get rid of the upper level catalogue $sub =substr ($phone, 0, 3); Get the first three digits of the number if (In_array ($sub, $sunum)) { $num =substr ($phone, 3,4); $search =file ($dbpath. $sub); $result =str_replace ($num.) = "," ", $search [$num]); Working with Data Return (strlen ($result) >1)? $result: "0"; }else{ Return "temporarily does not support $sub";
} } } ?> |