1. Go to this page and download the library: Download kzykhys/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/ */
kzykhys / parallel example snippets
php
use KzykHys\Parallel\Parallel;
n([
function () {
echo "task#1 start\n";
sleep(2);
echo "task#1 end\n";
},
function () {
echo "task#2 start\n";
sleep(3);
echo "task#2 end\n";
}
]);
echo "Done\n";
php
use KzykHys\Parallel\Parallel;
rallel->values([
function () {
return 'item';
},
'foo' => function () {
// return value must be serializable
return new \DateTime('2013-01-01');
}
]);
var_dump($values);
php
use KzykHys\Parallel\Parallel;
ch(['a', 'b'], function ($str) {
echo "start task with '$str'\n";
sleep(3);
echo "finish task with '$str'\n";
});
php
use KzykHys\Parallel\Parallel;
rallel->map([1, 2, 3], function ($value) {
return $value * 2;
});
var_dump($values);