PHP code example of globalis / wp-datanova-cities

1. Go to this page and download the library: Download globalis/wp-datanova-cities 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/ */

    

globalis / wp-datanova-cities example snippets




use \Globalis\WP\Datanova\Cities;

Cities::instance()->getCities('01090'));

// Array
// (
//     [0] => Array
//         (
//             [ville] => FERNEY VOLTAIRE
//             [code_postal] => 01210
//             [code_insee] => 01160
//         )
//
//     [1] => Array
//         (
//             [ville] => ORNEX
//             [code_postal] => 01210
//             [code_insee] => 01281
//         )
//
//     [2] => Array
//         (
//             [ville] => VERSONNEX
//             [code_postal] => 01210
//             [code_insee] => 01435
//         )
//
// )

Cities::instance()->getCities('ABCDE'));

// Array
// (
// )



use \Globalis\WP\Datanova\Cities;

Cities::instance()->getCitiesNames('01090'));

// Array
// (
//     [0] => FERNEY VOLTAIRE
//     [1] => ORNEX
//     [2] => VERSONNEX
// )

Cities::instance()->getCitiesNames('ABCDE'));

// Array
// (
// )



use \Globalis\WP\Datanova\Cities;

Cities::instance()->isCityValid('PARIS 15', '75014')

// (boolean) false

Cities::instance()->isCityValid('PARIS 15', '75015')

// (boolean) true

Cities::instance()->isCityValid('FOO', 'BAR')

// (boolean) false