This function returns an array of elements from low to high, inclusive. If low > high, the sequence will be from high to low.
Note: If the low parameter is higher than the high parameter, the range array will be from high to low.
Returns an array of elements from low to high
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 |
Syntax
range(low,high,step)
Example
$array = range(0,4);
print_r ($array);
Output
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 )