PHP code example of generoi / finnish-postal-codes
1. Go to this page and download the library: Download generoi/finnish-postal-codes 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/ */
generoi / finnish-postal-codes example snippets
use FinnishPostalCodes\PostalCodes;
use FinnishPostalCodes\Language;
// Create instance with language
$sv = PostalCodes::sv();
$city = $sv->getCity('00900'); // Returns "HELSINGFORS"
$fi = PostalCodes::fi();
$city = $fi->getCity('00900'); // Returns "HELSINKI"
// Get full record
$record = $fi->getRecord('00900');
echo $record->postcode_fi_name; // "HELSINKI"
echo $record->municipal_name_fi; // "Helsinki"
echo $record->ad_area_fi; // "Helsinki-Uusimaa"
// Check if postal code exists
if ($fi->exists('00900')) {
// ...
}
// Get all postal codes
$allPostcodes = $fi->getAllPostcodes();
// Iterate over all records (memory efficient)
foreach ($fi->getFull() as $postcode => $record) {
// Process each record
}
$fiData = bash
php scripts/fetch.php