PHP code example of neu / pipe7

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

    

neu / pipe7 example snippets


use Neu\Pipe7\CollectionPipe;

$data = [1,2,3];
$p = CollectionPipe::from($data);
// or with the shorthand
$p = pipe($data);

$doubled = $p->map(function($x){ return $x * 2; })->toArray();
// if you're using php7.4 or later,
// better use arrow functions for more concise code
$doubled = $p->map(fn($x) => $x * 2)->toArray();

$even = $p->filter(fn($x) => $x % 2 === 0)->toArray();

$total = $p->reduce(fn($carry, $x) => $carry + $x, 0);