PHP code example of bvtterfly / cycler

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

    

bvtterfly / cycler example snippets


$cycle = cycler('odd', 'even');
$numbers = [1,2,3,4,5,6];
foreach ($numbers as $number) {
    echo "{$number} is {$cycle->next()}";
}
// prints 1 is odd 2 is even 3 is odd 4 is even 5 is odd 6 is even

$adsCycle = cycler(false, false, true);
foreach ($posts as $post) {
    // show post
    if ($adsCycle->next()) {
        // show add
    }
}