BLOG // July 13, 2021
Use range() in PHP for loops
Using the range() function makes your for loops in PHP far cleaner to read. Compare this "old" version:
$start = 0;
$end = 1000;
for ($i = $start; $i < $end; $i++) {
// do work
}
Now have a look using range:
$start = 0;
$end = 1000;
foreach (range($start, $end) as $i) {
// do work
}
Comments
Subscribe to new articles
If you enjoy my content, consider subscribing. You will only receive new blog stories, no other email.