PHP code example of salymmbise / tanzania-banks

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

    

salymmbise / tanzania-banks example snippets

bash


mbise\TanzaniaBanks\BankList;

// Instantiate the BankList class
$bankList = new BankList();

// Get all banks
$banks = $bankList->getBanks();
echo "Banks in Tanzania:\n";
print_r($banks);

// Get branches for National Bank of Commerce
$branches = $bankList->getBranches('National Bank of Commerce');
echo "\nBranches of National Bank of Commerce:\n";
print_r($branches);

// Get SWIFT code for a specific branch of National Bank of Commerce
$swiftCode = $bankList->getSwiftCode('National Bank of Commerce', 'Dar es Salaam - Corporate Branch');
echo "\nSWIFT Code of National Bank of Commerce Dar es Salaam - Corporate Branch:\n";
echo $swiftCode . "\n";

// Get branches for CRDB Bank
$branches = $bankList->getBranches('CRDB Bank');
echo "\nBranches of CRDB Bank:\n";
print_r($branches);

// Get SWIFT code for a specific branch of CRDB Bank
$swiftCode = $bankList->getSwiftCode('CRDB Bank', 'Dar es Salaam - Azikiwe Branch');
echo "\nSWIFT Code of CRDB Bank Dar es Salaam - Azikiwe Branch:\n";
echo $swiftCode . "\n";

## Methods
getBanks()
Returns an array of all banks available in Tanzania.

$banks = $bankList->getBanks();

getSwiftCode($bank, $branch)
Returns the SWIFT code for a specific branch of a bank.

$swiftCode = $bankList->getSwiftCode('National Bank of Commerce', 'Dar es Salaam - Corporate Branch');