danack/looping-exec

A function for running code in a loop.

Fund package maintenance!
Danack

0.3.0 2021-03-03 17:59 UTC

This package is auto-updated.

Last update: 2024-03-29 04:19:22 UTC


README

A function library to allow repeatedly running a callable for a certain amount of time before returning.

Please note, parameters are open to change.

Example

<?php

require __DIR__ . "/vendor/autoload.php";

use function LoopingExec\continuallyExecuteCallable;

$fn = function () {
    static $count = 0;
    echo "Hello world: $count\n";
    $count += 1;
};

continuallyExecuteCallable(
    $fn,
    5,
    1000,
    0
);

// output is:
// Hello world: 0
// Hello world: 1
// Hello world: 2
// Hello world: 3
// Hello world: 4