PHP code example of srtfisher / money
1. Go to this page and download the library: Download srtfisher/money 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/ */
srtfisher / money example snippets
use Money\Money;
$fiveEur = Money::Euro(500);
$tenEur = $fiveEur->add($fiveEur);
list($part1, $part2, $part3) = $tenEur->allocate(array(1, 1, 1));
assert($part1->equals(Money::Euro(334)));
assert($part2->equals(Money::Euro(333)));
assert($part3->equals(Money::Euro(333)));
// Format
// $1,234.56
echo Money::USD(123456)->format();
$dollars = $cents * 100;
$cents = $dollars / 100;