Example 1 — Create Number Sequences
The simplest use is a run of whole numbers. A step changes the gap between values.
<?php
echo implode(", ", range(1, 5)), PHP_EOL;
echo implode(", ", range(0, 10, 5)), PHP_EOL; How It Works
- range(1, 5) builds an array with the numbers from 1 to 5.
- implode() joins the values with a comma and a space to make a readable line.
- range(0, 10, 5) adds 5 each time, so the values are 0, 5 and 10.
- The end value is included because the step lands on it exactly.

