PHP code example of struggle-for-php / sfp-iterator-url
1. Go to this page and download the library: Download struggle-for-php/sfp-iterator-url 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/ */
struggle-for-php / sfp-iterator-url example snippets
class Bigsize extends IteratorIterator
{
public function current()
{
$str = str_repeat($this->getInnerIterator()->current(), 8192);
return $str;
}
}
$iterator = new Bigsize(new ArrayIterator(range(1, 100)));
$fp = (new IteratorUrl)->open($iterator);
$body = new Zend\Diactoros\Stream($fp);
// emit
fpassthru($body->detach());
echo formatBytes(memory_get_usage()); // 278.97 KB <-- look
// echo $body->__toString(); // 1.75MB