PHP code example of black / address

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

    

black / address example snippets


$country = new Address\Country("France", "FR");
echo $country->getName(); // return (string) France

$country = Address\Country::buildFromISOCode("FR");

$country = Address\Country::buildFromName("France");

$street = new Address\Street(1600, "Amphitheatre Pkwy");
$street->getValue(','); // return (string) 1600, Amphitheatre Pkwy

$street  = new Address\Street(1600, "Amphitheatre Pkwy");
$country = new Address\Country("United States", "US");

$postalAddress = new Address\PostalAddress(
    $street,
    94043,
    "Mountain View",
    "CA",
    23,
    $country
);


$street  = new Address\Street(1600, "Amphitheatre Pkwy");
$country = new Address\Country("United States", "US");

$postalAddress = new Address\PostalAddress(
    $street,
    94043,
    "Mountain View",
    "CA",
    23,
    $country
);

$formatter = new Address\PostalAddressFormatter($postalAddress);
echo $formatter->format("%u %n %P %a"); // return 1600 Amphitheatre Pkwy 94043 United States