PHP code example of louisgab / php-calc

1. Go to this page and download the library: Download louisgab/php-calc 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/ */

    

louisgab / php-calc example snippets


$result = round(($b != 0 ? ((1+$a)/$b) : $c)*0.25, 2)

$result = Number::of($b)
    ->when(Number::of($b)->isZero(),
        fn($b) => $c
        fn($b) => Number::one()->plus($a)->divide($b),
    )
    ->multiply(0.25)
    ->round(2)
    ->value()

use Louisgab\Calc\Number;

Number::of($anything);

public function carsNeeded(Number $people, Number $placesPerCar): int
{
    return $people->divide($placesPerCar)->round(0)->toInt();
}
bash
composer