PHP code example of infrajs / each

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

    

infrajs / each example snippets


$counter = 0;
$el = [2, [4, 6], 5];
Each::exec($el, function ($b) use (&$counter) {
    $counter++;
    if ($counter === 3) {
        assert(6 === $b);
    }
});

$elements = ['9' => '42', 8, 4, 5, 3];
assert(true === Each::isAssoc($elements));
$elements = [9, 8, 4, 5, 3];
assert(false === Each::isAssoc($elements));

$el = 12;
assert(true === Each::isInt($el));
$el = '12';
assert(true === Each::isInt($el));

$a = 1;
$b = &$a;
assert(true === Each::isEqual($a, $b));

phpunit --bootstrap Each.php tests/EachTest

$counter = 0;
$el = [2, [4, 6], 5];
Each::exec($el, function ($b) use (&$counter) {
    $counter++;
    if ($counter === 3) {
        assert(6 === $b);
    }
});

$elements = ['9' => '42', 8, 4, 5, 3];
assert(true === Each::isAssoc($elements));
$elements = [9, 8, 4, 5, 3];
assert(false === Each::isAssoc($elements));

$el = 12;
assert(true === Each::isInt($el));
$el = '12';
assert(true === Each::isInt($el));

$a = 1;
$b = &$a;
assert(true === Each::isEqual($a, $b));

phpunit --bootstrap Each.php tests/EachTest