1. Go to this page and download the library: Download toolkit/stdlib 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/ */
use Toolkit\Stdlib\Util\Stream\DataStream;
use Toolkit\Stdlib\Util\Stream\ListStream;
$userList = ListStream::of($userModels)
->filter(fn($userModel) => $userModel->age > 20) // only need age > 20
->map(function ($userModel) {
// only need field: age, name
return [
'age' => $userModel->age,
'name' => $userModel->name,
];
})
->toArray();
vdump($userList);