PHP code example of superscript / interval

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

    

superscript / interval example snippets


use Superscript\Interval\Interval;

// Create from string notation
$interval = Interval::fromString('[1,5]');  // Closed interval
$interval = Interval::fromString('(1,5)');  // Open interval 
$interval = Interval::fromString('[1,5)');  // Right-open interval
$interval = Interval::fromString('(1,5]');  // Left-open interval
$interval = Interval::fromString('[1,)');  // Left-bounded interval (infinite upper bound)
$interval = Interval::fromString('(,1]');  // Right-bounded interval (infinite lower bound)

$interval = Interval::fromString('[2,5]');

$interval->isGreaterThan(1);      // true
$interval->isGreaterThanOrEqualTo(2);  // true
$interval->isLessThan(6);         // true
$interval->isLessThanOrEqualTo(5);     // true