PHP code example of nerd-components / lambda

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

    

nerd-components / lambda example snippets


use function Lambda\l;

// Unindexed placeholders mode
$sum = l('$ + $');

echo $sum(2, 4); // will output 6


// Indexed placeholders mode
$func = l('$0 + ($0 * $1)');

echo $func(2, 6); // will output 14


// Filtering function
$numbers = range(1, 10);

$evens = array_filter(l('$ % 2 == 0'), $numbers); // will produce array [2, 4, 6, 8, 10]