PHP code example of agallou / departements

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

    

agallou / departements example snippets


$departements = new \agallou\Departements\Collection();
var_dump($departements->getLabel('29'));
//string(10) "Finistère"

$departements = new \agallou\Departements\Collection();
var_dump($departements->getAll());

$departements = new \agallou\Departements\Collection();
var_dump($departements->getLabel(1, true));
//string(3) "Ain"

$departements = new \agallou\Departements\Collection();
foreach ($departements as $code => $label) {
  var_dump($code, $label);
}
//string(2) "01"
//string(3) "Ain"
//string(2) "02"
//string(5) "Aisne"
//...
//string(7) "Mayotte"