PHP code example of cyril-verloop / iterator

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

    

cyril-verloop / iterator example snippets




declare(strict_types=1);

namespace MyNamespace;

use MyNamespace\Item;

class Items extends IntPosition
{
    public function add(Item $item): void
    {
        $this->list[count($this->list)] = $item;
    }

    public function current(): Item
    {
        return parent::current();
    }
}

$items->add($item1);
$items->add($item2);

foreach($items as $item) {
    // Do something.
}