2017 © Pedro Peláez
 

library tomoney

A library to convert a number in various money formats

image

linuxartisan/tomoney

A library to convert a number in various money formats

  • Saturday, May 26, 2018
  • by sandesh87
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

About ToMoney

A simple PHP library to convert a number to money format., (*1)

Installation

With Composer

$ composer require linuxartisan/tomoney

Alternatively, you may add the following in composer.json file., (*2)

{
    "require": {
        "linuxartisan/tomoney": "*"
    }
}

And then execute, (*3)

$ composer install

After installation, to dump the autoloader, execute, (*4)

$ composer dump-autoload

Usage

<?php

require __DIR__ . '/vendor/autoload.php';

use LinuxArtisan\ToMoney\Money;

echo Money::formatToIndian(123456127.73); // to Indian
// "12,34,56,127.73"

echo Money::formatToUS(123456127.73); // to US
// "123,456,127.73"

echo Money::formatTo('en_GB', 123456127.73); // to custom
// "123,456,127.73"

Numeric values may be passed as strings too, (*5)

echo Money::formatToIndian('12345.67'); // to Indian
echo Money::formatToUS('1234.56'); // to US
echo Money::formatTo('en_GB', '1234.56'); // to custom

But this is not recommended, as a non-numeric string will be returned as '0'., (*6)

return Money::formatTo('en_GB', "12abcd127.731");

will return 0 as a string., (*7)

Also, if a particular locale is not supported, the same amount will be returned as a string without formatting., (*8)

return Money::formatTo('some_unsupported_locale', 12345);
// "12345"

Note

To view all the available locales on your system, give the following command in the terminal, (*9)

$ locale -a

These locales may be used as argument to the formatTo function., (*10)

Find me here:

Contact me on Codementor, (*11)

The Versions

26/05 2018

dev-master

9999999-dev

A library to convert a number in various money formats

  Sources   Download

MIT

The Requires

  • php ^5.3 || 7.*

 

by Sandesh Patil

26/05 2018

1.0.2

1.0.2.0

A library to convert a number in various money formats

  Sources   Download

MIT

The Requires

  • php ^5.3 || 7.*

 

by Sandesh Patil

22/05 2018

1.0.1

1.0.1.0

A library to convert a number in various money formats

  Sources   Download

MIT

The Requires

  • php ^5.3

 

by Sandesh Patil

21/05 2018

1.0.0

1.0.0.0

A library to convert a number in various money formats

  Sources   Download

MIT

The Requires

  • php ^5.3

 

by Sandesh Patil

21/05 2018

1.0.0-beta

1.0.0.0-beta

A library to convert a number in various money formats

  Sources   Download

MIT

The Requires

  • php ^5.3

 

by Sandesh Patil

19/05 2018

0.0.1

0.0.1.0

A library to convert a number in various money formats

  Sources   Download

MIT

The Requires

  • php ^5.3

 

by Sandesh Patil