PHP range() Function

PHP range Function


Definition :

In PHP Array function range function is inbuilt function.range() function is used to  creates an array containing a range of elements.

Syntax

   range(low, high, step)

Parameter 
Parameter Description
low Required. Specifies the lowest value of the array
high Required. Specifies the highest value of the array
step Optional. Specifies the increment used in the range. Default is 1

Example1 : Given below exaple Create an array containing a range of elements from "3" to "7".

 

Output : 

Array
(
    [0] => 3
    [1] => 4
    [2] => 5
    [3] => 6
    [4] => 7
)

Example2 : Return an array of elements from "10" to "40" and increment by 8

Output :

Array
(
    [0] => 10
    [1] => 18
    [2] => 26
    [3] => 34
)