The range() function is an inbuilt function in PHP which is used to create an array of elements of any kind such as integer, alphabets within a given range(from low to high) i.e, list’s first element is considered as low and last one is considered as high.
array range(low, high, step)
Parameters: This function accepts three parameters as described below:
- low: It will be the first value in the array generated by range() function.
- high: It will be the last value in the array generated by range() function.
- step: It is used when the increment used in the range and it’s default value is 1.
Return Value: It returns an array of elements from low to high.
Input : range(0, 6) Output : 0, 1, 2, 3, 4, 5, 6 Explanation: Here range() function print 0 to 6 because the parameter of range function is 0 as low and 6 as high. As the parameter step is not passed, values in the array are incremented by 1. Input : range(0, 100, 10) Output : 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 Explanation: Here range() function accepts parameters as 0, 100, 10 which are values of low, high, step respectively so it returns an array with elements starting from 0 to 100 incremented by 10.
Below programs illustrate range() function in PHP:
0 1 2 3 4 5 6
0 20 40 60 80 100
a b c d e f g h i j
p o n m l k j i h g f e d c b a
- D3.js | d3.range() function
- CSS | :in-range Selector
- CSS | :out-of-range Selector
- HTTP headers | Range
- HTTP headers | Content-Range
- HTML | DOM Input Range Object
- HTML | <input type="range">
- HTML | DOM Input Range value Property
- HTML | DOM Input Range name Property
- HTML | DOM Input Range min Property
- HTML | DOM Input Range max Property
- PHP program to Generate the random number in the given range (min, max)
- HTML | DOM Input Range step Property
- HTML | DOM Input Range stepUp() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.