PHP code example of antevemus / alinq-parallel

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

    

antevemus / alinq-parallel example snippets




declare(strict_types=1);

use Antevemus\ALinqParallel\ALinqParallelCollection;
use App\Work\Primes;

// Count the primes below each limit, four limits at a time, each in a worker process
$counts = ALinqParallelCollection::from([10_000, 20_000, 30_000, 40_000])
    ->selectParallel([Primes::class, 'countBelow'], workers: 4) // a static method travels by name
    ->where(fn(int $count) => $count > 2000) // the core operators chain after it, in this process
    ->toArray();

// Result: [2262, 3245, 4203]