PHP code example of andydune / select-closest-number-from-set

1. Go to this page and download the library: Download andydune/select-closest-number-from-set 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/ */

    

andydune / select-closest-number-from-set example snippets


use AndyDune\SelectClosestNumberFromSet;
$object = new SelectClosestNumberFromSet([0, 20, 40]);
$next = $object->select(-5); // = 0
$next = $object->select(5); // = 0
$next = $object->select(39); // = 20
$next = $object->select(100); // = 40

use AndyDune\SelectClosestNumberFromSet;
$object = new SelectClosestNumberFromSet([0, 20, 40]);
$object->selectHigh();
$next = $object->select(-5); // = 0
$next = $object->select(5); // = 20
$next = $object->select(39); // = 40
$next = $object->select(100); // = 40

php composer.phar update