PHP code example of ruchee / phone_attribution

1. Go to this page and download the library: Download ruchee/phone_attribution library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ruchee / phone_attribution example snippets




chee\PhoneAttribution\Parse;

$parse = new Parse();
$data  = $parse->parseOne('13713462969');
print_r($data);

// 输出结果
Array
(
    [status] => 1
    [info] => 解析成功
    [data] => Array
        (
            [province] => 广东
            [city] => 东莞
            [postcode] => 523000
            [prefix] => 0769
            [spname] => 中国移动
        )

)



chee\PhoneAttribution\Parse;

$parse = new Parse();

$phone_list = [
    '18520796150',
    '18745222111',
];
$data = $parse->parseList($phone_list);
print_r($data);

// 输出结果
Array
(
    [status] => 1
    [info] => 解析成功
    [data] => Array
        (
            [18520796150] => Array
                (
                    [province] => 广东
                    [city] => 广州
                    [postcode] => 510000
                    [prefix] => 020
                    [spname] => 中国联通
                )

            [18745222111] => Array
                (
                    [province] => 黑龙江
                    [city] => 齐齐哈尔
                    [postcode] => 161000
                    [prefix] => 0452
                    [spname] => 中国移动
                )

        )

)



chee\PhoneAttribution\Parse;

$parse = new Parse(__DIR__.'/phone.dat');

// 更新数据源
// wget -c https://github.com/xluohome/phonedata/blob/master/phone.dat?raw=true -O phone.dat