PHP code example of wi1dcard / china-divisions

1. Go to this page and download the library: Download wi1dcard/china-divisions 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/ */

    

wi1dcard / china-divisions example snippets


use ChinaDivisions;

$division = new Division(1); // 参数为 DivisionID;1 代表中国,即根结点。

$division->self(); // 获取自身信息,返回键值数组
$division->children(); // 获取下一级子区划,返回 Division 对象数组
$division->parent(); // 获取上一级父区划,返回 Division 对象
$division->ancestors(); // 获取所有上级父区划,返回 Division 对象数组
$division->breadcrumb(); // 根据父区划拼接可读地址,返回字符串
$division->guess(); // 地址录入联想
$division->search(); // 地址规范查询
bash
composer install
php scripts/crawler.php