PHP code example of montopolis / fda-nutrition-rounding-php

1. Go to this page and download the library: Download montopolis/fda-nutrition-rounding-php 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/ */

    

montopolis / fda-nutrition-rounding-php example snippets




$rounder = new Montopolis\Fda\Rounding();

$rounder->calorie(123)->toInt(); // outputs 120
$rounder->calorie(123)->toFloat(); // outputs 120.0
$rounder->calorie(123)->toString(); // outputs "120 g"

$rounder->carbohydrate(0.51)->toString(); // outputs "less than 1 g"

 $rounder->alcohol($value)->toInt();
 $rounder->betaCarotene($value)->toInt();
 $rounder->calorie($value)->toInt();
 $rounder->carbohydrate($value)->toInt();
 $rounder->cholesterol($value)->toInt();
 $rounder->dietaryFiber($value)->toInt();
 $rounder->fat($value)->toInt();
 $rounder->mineral($value)->toInt();
 $rounder->otherFiber($value)->toInt();
 $rounder->potassium($value)->toInt();
 $rounder->protein($value)->toInt();
 $rounder->sodium($value)->toInt();
 $rounder->sugar($value)->toInt();
 $rounder->vitamin($value)->toInt();