Cell phone number attribution to query Code _php tutorial

Source: Internet
Author: User
Tags mysql tutorial
The cell phone number attribution query code is a PHP open source phone Attribution query system, the system does not rely on large databases such as MySQL, but rely on text, because, generally a mobile phone number, in the query system, the decision is the first 7 bits

Cell phone number attribution to query code
/*
The cell phone number attribution query code is a PHP tutorial open source Phone Attribution query system, the system does not rely on the MySQL tutorial, such as large database tutorial, but rely on text, because, generally a mobile phone number, in the query system, the decision is the first 7 bits
*/

If ($_post)
{
$phone = (isset ($_post["Phone"]))? $_post["Phone"]:d ie ("please return");
echo "You queried: $phone, Data:". Getphone ($phone);


Function Getphone ($phone) {
$dbpath = "datas/";
$len =strlen ($phone);
if ($len!=11) {
return Mobile phone number only supports 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 the supported mobile number prefix
Array_splice ($sunum, 0, 1);//Cancel the current directory
Array_splice ($ sunum,0,1); Remove the top-level directory
$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]); Process data
Return (strlen ($result) >1)? $result: "0";

}else{
Return "temporarily does not support $sub";

}

}
}
?




Cell phone number attribution to query




http://www.bkjia.com/PHPjc/631991.html www.bkjia.com true http://www.bkjia.com/PHPjc/631991.html techarticle the cell phone number attribution query code is a PHP open source phone Attribution query system, the system does not rely on the large database such as MySQL, but rely on text, because, generally a mobile phone number ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.