PHP code example of bvp / prefecture

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

    

bvp / prefecture example snippets


use BVP\Prefecture\Prefecture;
use BVP\Prefecture\Region;

Prefecture::from(2); // Enums\Prefecture::aomori
Prefecture::from('青森県'); // Enums\Prefecture::aomori
Prefecture::from('aomori'); // Enums\Prefecture::aomori (case-insensitive)

Prefecture::from(2)->name(); // '青森県'
Prefecture::from(2)->shortName(); // '青森'
Prefecture::from(2)->hiraganaName(); // 'あおもりけん'
Prefecture::from(2)->katakanaName(); // 'アオモリケン'
Prefecture::from(2)->englishName(); // 'aomori'
Prefecture::from(2)->region(); // Enums\Region::tohoku

Region::from('東北'); // Enums\Region::tohoku
Region::from('tohoku')->prefectures(); // [aomori, iwate, miyagi, akita, yamagata, fukushima]

json_encode(Prefecture::from(2));
// {"number":2,"name":"青森県","short_name":"青森", ... }