PHP code example of letsgoi / custom-collection

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

    

letsgoi / custom-collection example snippets


use Letsgoi\CustomList\CustomList;

class ItemList extends CustomList
{
    protected function getListType(): string
    {
        return Item::class;  
    }
}

//

$items = [new Item(), new Item(), ...];
$list = new ItemList($items);

foreach ($list as $item) {
    //
}

$list->get(0); // 'item'

$list->get(); // ['item', 'item', ...]

$list->add($item);

$list->merge($list1, $list2 ...);