Ranger allows you to mimic the range function in PHP as an Iterator, conserving memory for large ranges.
composer require crowdstar/ranger:~1.0.0
<?php
foreach (range(1, 100000) as $number) {
echo $number;
}
<?php
use CrowdStar\Iterators\Ranger;
$range = Ranger::start(1, 100000);
foreach ($range as $number) {
echo $number;
}