PHP code example of pulli / collection-macros

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

    

pulli / collection-macros example snippets


$collection = Collection::mapToCollectionFrom([['test' => 1], 2, 3]);

$collection->get(0)->get('test'); // returns 1

// Item has a toArray() public method, then it can be wrapped into a collection like this:
$collection = Collection::mapToCollectionFrom([Item(), Item()], true);

Collection::make([1, 2, 3])->positive() // returns true
Collection::make()->positive() // returns false

// Item has a toArray() public method, then it can be wrapped into the collection like this:
$array = Collection::recursiveToArrayFrom(['item1' => Item(), 'item2' => Item()]);