PHP code example of diephp / sequences

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

    

diephp / sequences example snippets


$sequence = new \DiePHP\Sequences\ExponentialSequence(1, 100);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(1)
 *  int(2)
 *  int(4)
 *  int(8)
 *  int(16)
 *  int(32)
 *  int(64)
......
 */

$sequence = new \DiePHP\Sequences\LogarithmicSequence(1000000, 100);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(1000000)
 *  int(2866747)
 *  int(8218239)
 *  int(23559615)
 *  int(67539464)
 *  int(193618581)
 *  int(555055559)
 *  int(1591204067)
 *  int(4561580082)
 *  int(13076897726)
......
 */

$sequence = new \DiePHP\Sequences\LogarithmicSequence(10, 50);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(10)
 *  int(20)
 *  int(40)
 *  int(80)
 *  int(159)
 *  int(315)
 *  int(623)
 *  int(1231)
 *  int(2432)
 *  int(4805)
......
 */

$sequence = new \DiePHP\Sequences\ProgressiveSequence(100, 50);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(100)
 *  int(150)
 *  int(250)
 *  int(400)
 *  int(600)
 *  int(850)
 *  int(1150)
......
 */

$sequence = new \DiePHP\Sequences\LinearSequence(100, 50);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(100)
 *  int(150)
 *  int(200)
 *  int(250)
 *  int(300)
 *  int(350)
 *  int(400)
......
 */

$sequence = new \DiePHP\Sequences\LinearSequence(0, 10);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(0)
 *  int(10)
 *  int(20)
 *  int(30)
 *  int(40)
......
 */

$sequence = new \DiePHP\Sequences\FibonacciSequence(2);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(2)
 *  int(2)
 *  int(4)
 *  int(6)
 *  int(10)
 *  int(16)
 *  int(26)
......
 */

$sequence = new \DiePHP\Sequences\InfiniteSequence(2);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(2)
 *  int(3)
 *  int(4)
 *  int(5)
 *  int(6)
 *  int(7)
 *  int(8)
......
 */

$sequence = new \DiePHP\Sequences\UniqRandSequence(1, 100);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(34)
 *  int(20)
 *  int(75)
 *  int(88)
 *  int(4)
 *  int(72)
 *  int(98)
 *  int(21)
 *  int(9)
......
 */

$sequence = new \DiePHP\Sequences\RandSequence(1, 100);
foreach ($sequence AS $value) {
    var_dump($value);
}
/**
 *  int(2)
 *  int(58)
 *  int(51)
 *  int(55)
 *  int(60)
 *  int(54)
 *  int(51)
 *  int(50)
 *  int(55)
......
 */