PHP Array Elements Range

What is range() Function?

Explanation

The "range()" function creates an array containing a range of elements.

Syntax:


range(low,high,step)

In the above syntax the parameter "low" is lowest value of the array, "high" is the highest value of the array, "step" is the increment used in the range, by default its 1.

Example :


<?php
$number = range(0,50,10);
print_r ($number);
?>
Result :

Array
{
[0] => 0
[1] => 10
[2] => 20
[3] => 30
[4] => 40
[5] => 50
}

In the above example the number from the lowest range "0" to highest range "50" is displayed with an increment of "10".

PHP Topics


Ask Questions

Ask Question