PHP code example of pepegar / streams-php
1. Go to this page and download the library: Download pepegar/streams-php 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/ */
pepegar / streams-php example snippets
use Streams as S;
$collection = Car::model()->findAll(); // Returns an array of Car objects
$carStream = new S\Stream($collection);
$newCollection = $carStream
->filter(function( $car ) {
return ($car->price > 36000); // return only expensive cars!
})->map(function( $car ) {
$car->setCo2EmissionTaxes(20); // Since is an expensive car, lets make the people who drive it more poor :D
return $car;
})->getElements();
json
"pepegar/streams-php": "dev-master"