PHP code example of easyframework / collections

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

    

easyframework / collections example snippets


  $person1 = new \stdClass();
  $person1->name = 'John';
  $person1->age = 25;
  
  $person2 = new \stdClass();
  $person2->name = 'Maria';
  $person2->age = 30;
  
  $person3 = new \stdClass();
  $person3->name = 'Anderson';
  $person3->age = 15;
     
  $collection = new Collections\Vector();
  $collection->add($person1);
  $collection->add($person2);
  $collection->add($person3);
  
  $collection->filter(function($person){
        return $person->age > 18;
  })->each(function($item){
        echo $item->name; //John and Maria
  });