range

PHP 4, PHP 5, PHP 7, PHP 8
range - Create an array containing a range of elements

range( string|int|float$start, string|int|float$end, [int|float$step = 1] ): array

Create an array containing a range of elements.

Parameters

start

First value of the sequence.

end

The sequence is ended upon reaching the end value.

step

If a step value is given, it will be used as the increment (or decrement) between elements in the sequence. step must not equal 0 and must not exceed the specified range. If not specified, step will default to 1.

Return Values

Returns an array of elements from start to end, inclusive.

Notes

Note:

Character sequence values are limited to a length of one. If a length greater than one is entered, only the first character is used.

Related Functions

Example of range

Show all examples for range

PHP Version: