PHP code example of rubicon / loop

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

    

rubicon / loop example snippets


namespace Rubicon\Loop;

(new Loop([
        'interval' => 100,
        'repeat'   => 26,
    ]))
    ->attach(LoopEvent::EVENT_LOOP_START, function() {
        echo 'start...' . PHP_EOL;
    })
    ->attach(LoopEvent::EVENT_EXECUTE_POST, function(LoopEvent $event) {
        echo $event->getResult() . PHP_EOL;
    })
    ->attach(LoopEvent::EVENT_LOOP_STOP, function(LoopEvent $event) {
        echo $event->getException()->getMessage() . PHP_EOL;
    })
    ->invoke(function(LoopEvent $event) {
        $result = $event->getResult();
        return $result ? ++$result : 'A';
    })
;