PHP code example of limen / redenvelope

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

    

limen / redenvelope example snippets


use Limen\RedEnvelope\Envelope;

$id = '123';                    // unique id
$remain = 212.23;               // envelope remain amount
$dividend = 10;                 // how many fragments to divide amount into
$minAssignment = 10.1;          // minimum value of each assignment
$precision = 2;                 // assignment precision

$varianceFactor = 1.0;          // Appropriate value should between 0.5 and 1.5, 1.0 may be the best.
                                // The greater this value, the greater the variance of the divided sequence is.

$envelope = new Envelope($id);

$envelope->setRemain($remain)
    ->setDividend($dividend);
    ->setPrecision($precision)
    ->setMinAssignment($minAssignment)
    ->setVarianceFactor($varianceFactor);

$assignment = $envelope->open();