PHP code example of revinate / sequence

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

    

revinate / sequence example snippets



Revinate\Sequence\Sequence;

$dataSet = array(1, 2, 3, 4, 5);
$seq = Sequence::make($dataSet);

// At this point you have a sequence and you can do bunch of cool sequence stuff with it

$even = $seq->filter(static function($n) { return $n%2 == 0; });  // nothing is evaluated here because of lazy loading
foreach($even as $num) {
    echo "$num\n";
}


$twice = $seq->map(static function($n) { return $n * 2; });
foreach($twice as $num) {
    echo "$num\n";
}