Giter VIP home page Giter VIP logo

address-smart-parse's Introduction

address-smart-parse

使用默认数据源

$address = '18000000000 贵州黔南州平塘县卡蒲毛南族乡河中村 李子海 ';

$smartParse = new AddressSmartParse();

$res = $smartParse->parse($address);

print_r($res);
//output:
/* Array
(
    [province] => 贵州省
    [city] => 黔南布依族苗族自治州
    [district] => 平塘县
    [town] => 卡蒲毛南族乡
    [mobile] => 18000000000
    [name] => 李子海
    [address] => 河中村
)
*/

自定义数据源

class RegionService {
    
    public function getRegion($regionName)
    {
      
        $region = Region::query()->where('name','=',$name)->first(['id','name','parent_id']);
        return $region  ? $region->toArray() : '';

    }
}

$service = new RegionService();
$address = '18000000000 广东省中山市南头镇南头大道中59号 ';

$service = new RegionService();
$smartParse = new AddressSmartParse([$service,'getRegion']);
$res = $smartParse->parse($address);
print_r($res);

//output:
/* Array
(
    [province] => 广东省
    [city] => 中山市
    [district] => 
    [town] => 南头镇
    [mobile] => 18000000000
    [name] => 李子海
    [address] => 南头大道中59号
)
*/

address-smart-parse's People

Contributors

firezihai avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.