PHP Classes
elePHPant
Icontem

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    
Last Updated Ratings Unique User Downloads Download Rankings
2019-08-31 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 132 This week: 3All time: 8,942 This week: 127Up
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
  Performance   Level  
Name: Ogbemudia Osayawe <contact>
Classes: 3 packages by
Country: Malaysia Malaysia
Age: 36
All time rank: 368514 in Malaysia Malaysia
Week rank: 79 Up1 in Malaysia Malaysia Up
Innovation award
Innovation award
Nominee: 2x

 

Details

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:132
This week:3
All time:8,942
This week:127Up