1. Go to this page and download the library: Download rx/stream 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/ */
rx / stream example snippets
$source = new \Rx\React\FromFileObservable("example.csv");
$source
->cut() //Cut the stream by PHP_EOL
->map('str_getcsv') //Convert csv row to an array
->map(function (array $row) {
//Strip numbers from the first field
$row[0] = preg_replace('/\d+/u', '', $row[0]);
return $row;
})
->subscribe(
function ($data) {
echo $data[0] . "\n";
},
function ($e) {
echo "error\n";
},
function () {
echo "done\n";
}
);