Last Updated on Feb 15, 2023
Range is a function that creates an array containing the range of elements
It takes 3 arguments
Start is the first value
End is the last value
Step is the increment between first and last values default is 1
So let’s see some examples
A sequence of numbers between 1 and 6
$range = range(1,6); print_r($range); // Array (  => 1  => 2  => 3  => 4  => 5  => 6 )
A sequence of numbers between 1 and 6 with increments of 2 (step 2)
$range = range(1,6,2); print_r($range); // Array (  => 1  => 3  => 5 )
Now you know range funciton in PHP.
I recommend you to open a PHP file and try to define different ranges. Then try different steps for all those ranges.
If you have any suggestions, questions, or opinions, please contact me. I’m looking forward to hearing from you!
- range function in php
- steps in a range