PHP Classes

PHP Get Currency Symbol: Get the symbol of any given currency

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 163 All time: 8,931 This week: 68Up
Version License PHP version Categories
currency-util 1.0.0MIT/X Consortium ...5PHP 5, Finances
Description 

Author

This class can get the symbol of any given currency.

It can take as parameter of code of a given currency.

The class can return the symbol associated to that currency.

Innovation Award
PHP Programming Innovation award nominee
September 2019
Number 12
Each currency used in different countries to represent money has a symbol that is associated the currency which is used to make clear when a given money amount is displayed so other people can see prices or other values that represent money.

This class can return the symbols used to represent many currencies using pure PHP, thus not relying on the availability of any PHP extension for that purpose.

Manuel Lemos
Picture of Ogbemudia Osayawe
  Performance   Level  
Name: Ogbemudia Osayawe <contact>
Classes: 9 packages by
Country: Germany Germany
Age: 41
All time rank: 2885172 in Germany Germany
Week rank: 192 Up13 in Germany Germany Up
Innovation award
Innovation award
Nominee: 5x

Documentation

php currency-util

A simple library to lookup the currency symbol for a given currency code.

Installation

composer req terdia/currency-util

Usage

Get symbol from currency code

use Currency\Util\CurrencySymbolUtil;

CurrencySymbolUtil::getSymbol('GBP') //=> '£'
CurrencySymbolUtil::getSymbol('EUR') //=> '?'
CurrencySymbolUtil::getSymbol('USD') //=> '$'
CurrencySymbolUtil::getSymbol('NOT A VALID CODE') throw InvalidArgumentException

Get List of supported currency code


use Currency\Util\CurrencySymbolMapping;

var_dump(CurrencySymbolMapping::values())
// =>
[
 "USD" => "$",
 "GBP" => "£",
 "EUR" => "?",
 ?
]

Tests

vendor/bin/phpunit tests

Contribution

Feel free to contribute to this library.


  Files folder image Files (8)  
File Role Description
Files folder imagesrc (2 files)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENCE.md Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (8)  /  src  
File Role Description
  Plain text file CurrencySymbolMapping.php Class Class source
  Plain text file CurrencySymbolUtil.php Class Class source

  Files folder image Files (8)  /  tests  
File Role Description
  Plain text file CurrencySymbolUtilTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:163
This week:0
All time:8,931
This week:68Up