PHP code example of typomedia / collection

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

    

typomedia / collection example snippets


use Typomedia\Collection\Collection;

$data = [
    'Moretti' => [
        'name' => 'Style Ale',
        'style' => 'European Amber Lager',
        'alcohol' => '9.1%'
    ]
];

$collection = new Collection();
$key = md5(serialize($data));

$collection->set((object)$data, $key);
$collection->get($key);
$collection->first();
$collection->last();
$collection->keys();
$collection->find('name', 'Style Ale');
$collection->delete($key);