PHP code example of bradleyboy / range-converter

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

    

bradleyboy / range-converter example snippets


$converter = new Bradleyboy\Util\RangeConverter;
$converter->reduce([1,2,3,4,7,9,10,11]); // Returns: '1..4,7,9..11'

$converter = new Bradleyboy\Util\RangeConverter;
$converter->expand('1..4,7,9..11'); // Returns: [1,2,3,4,7,9,10,11]

$converter = new Bradleyboy\Util\RangeConverter;
$converter->setSeparator('.')
          ->setRangeSeparator('-')
          ->reduce([1,2,3,4,7,9,10,11]); // Returns: '1-4.7.9-11'