PHP code example of 4slovo / money
1. Go to this page and download the library: Download 4slovo/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/ */
4slovo / money example snippets
$money = Money::create(100);
$result = Money::create(100)->getAmount(); // $result = 100
$result = Money::create(100.99)->getAmount(); // $result = 100
$result = Money::create(100)->equal(Money::create(100)); // $result = true
$result = Money::create(100)->equalOrLess(Money::create(1000)); // $result = true
$result = Money::create(100)->equalOrLess(Money::create(100)); // $result = true
$result = Money::create(1000)->equalOrLess(Money::create(100)); // $result = false
$result = Money::create(100)->equalOrMore(Money::create(1000)); // $result = flase
$result = Money::create(100)->equalOrMore(Money::create(100)); // $result = true
$result = Money::create(1000)->equalOrMore(Money::create(100)); // $result = true
$result = Money::create(100)->less(Money::create(1000)); // $result = true
$result = Money::create(100)->less(Money::create(100)); // $result = false
$result = Money::create(1000)->less(Money::create(100)); // $result = false
$result = Money::create(100)->more(Money::create(1000)); // $result = false
$result = Money::create(100)->more(Money::create(100)); // $result = false
$result = Money::create(1000)->more(Money::create(100)); // $result = true
$result = Money::create(100)->add(Money::create(100)); // $result = Money::create(200)
$result = Money::create(100)->addList([
Money::create(100),
Money::create(100)
]); // $result = Money::create(300)
$result = Money::create(300)->sub(Money::create(100)); // $result = Money::create(200)
$result = Money::create(500)->subList([
Money::create(100),
Money::create(100)
]); // $result = Money::create(300)
$result = Money::create()->round(1000/3); // $result = 333
$result = Money::create(1000)->mul(1/3); // $result = Money::create(333)
$result = Money::create(1000)->div(3); // $result = Money::create(333)
$result = Money::create(3500000)->allocate(3); // $result = [Money::create(1166700), Money::create(1166700), Money::create(1166600)]