PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 162 All time: 8,931 This week: 571Up
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: 8 packages by
Country: Germany Germany
Age: 40
All time rank: 2943174 in Germany Germany
Week rank: 416 Up16 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  
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  /  src  
File Role Description
  Plain text file CurrencySymbolMapping.php Class Class source
  Plain text file CurrencySymbolUtil.php Class Class source

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:162
This week:0
All time:8,931
This week:571Up