1. Go to this page and download the library: Download timfennis/apply 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/ */
timfennis / apply example snippets
$list = [5, 6, 7, 8, 9, 10];
$gt4 = fn($n) => $n > 4;
$gt5 = fn($n) => $n > 5;
all($gt4)($list); // true because all items are greater than 4
all($gt5)($list); // false because not all items are greater than 5
$list = [5, 6, 7, 8, 9, 10];
$gt7 = fn($n) => $n > 7;
$gt20 = fn($n) => $n > 20;
any($gt7)($list); // true because all items are greater than 7
any($gt20)($list); // false because none of the items are greater than 20