PHP code example of dashifen / modcount

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

    

dashifen / modcount example snippets


$modcount = new Modcount(3);
echo $modcount->count();        // produces 0
echo $modcount->count();        // produces 1
echo $modcount->count();        // produces 2
echo $modcount->count();        // produces 0
echo $modcount->count();        // produces 1

$modcount = new Modcount(3);
echo $modcount();
echo $modcount();
echo $modcount();

$users = $database->getUsers();
$cols  = ["id", "name", "email", "phone"];
$modcount = new Modcount(sizeof($cols));

foreach($users as $user) {
    echo '<tr>';
    
    foreach($user as $datum) {
         echo sprintf('<td headers="%s">%s</td>',
            $cols[$modcount()],
            $datum);
    }
    
    echo '</tr>';
}