PHP code example of tourze / gb-t-12406

1. Go to this page and download the library: Download tourze/gb-t-12406 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/ */

    

tourze / gb-t-12406 example snippets


use Tourze\GBT12406\Currency;

// Get currency code
$currency = Currency::CNY;

// Get currency Chinese name
echo $currency->getLabel(); // Output: 人民币

// Get all available currencies
$allCurrencies = Currency::cases(); // Returns all 285 currencies

// Convert currency to array item
$item = Currency::CNY->toArray();
// [
//     'value' => 'CNY',
//     'label' => '人民币'
// ]

// Convert to select item (for frontend)
$selectItem = Currency::CNY->toSelectItem();
// [
//     'value' => 'CNY',
//     'label' => '人民币',
//     'text' => '人民币',
//     'name' => '人民币'
// ]

// Generate all available options
$options = Currency::genOptions();
// Returns array of ['value' => 'CODE', 'label' => 'Name'] items

// Disable specific currencies from options
$_ENV['enum-display:' . Currency::class . '-CNY'] = false;
$_ENV['enum-display:' . Currency::class . '-USD'] = false;

$filteredOptions = Currency::genOptions();
// CNY and USD will be excluded from the list

Currency::CNY->getLabel(); // "人民币"
Currency::USD->getLabel(); // "美元"
Currency::EUR->getLabel(); // "欧元"
Currency::JPY->getLabel(); // "日元"
Currency::GBP->getLabel(); // "英镑"