PHP code example of mibexx / collection

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

    

mibexx / collection example snippets


use mibexx\collection\Collection\Collection;
use mibexx\collection\Parser\CollectionParser;

$list = [
    'foo' => 'bar',
    'fuzz' => [
        'foo' => 'buzz'
    ]
];

$parser = new CollectionParser();
$collection = new Collection();
$parser->convertToCollection($list, $collection);
 
echo $collection->get('foo')->get(); // prints bar
echo $collection->get('fuzz')->get('foo')->get(); // prints buzz

use mibexx\collection\Collection\Collection;
use mibexx\collection\Parser\ArrayParser;

$parser = new ArrayParser();
$collection = new Collection();

$fuzz = new Collection();
$fuzz->set('foo', new SimpleElement('buzz'));

$collection->set('foo', new SimpleElement('bar'));
$collection->set('fuzz', new CollectionElement($fuzz));

$newList = $parser->convertToArray($collection);

print_r($newList);
/* equal to:
array(
    'foo' => 'bar',
    'fuzz' => [
        'foo' => 'buzz'
    ]
)
*/