英[reɪndʒ] 美[rendʒ]

n.Range; range; category; (mountains, houses, etc.) arrangement

vi.Search; change; extension; roaming

vt. Arrange; sort (in a certain position or order); classify...; wander

adj. Pasture, grazing area

Third person singular: ranges Plural: ranges Present participle: ranging Past tense: ranged Past participle: ranged

php range() function syntax

Function:Create an array containing elements in the specified range

Syntax:range(low,high,step)

Parameters:

Parameters Description
low Required. Specifies the minimum value of the array.
high Required. Specifies the maximum value of the array.
step Optional. Specifies the stepping between elements. The default is 1.

Description:This function creates an array containing integers or characters from low to high (including low and high). If high is smaller than low, return the array in reverse order.

php range() function example


Run instance»

Click the "Run instance" button to view the online instance

Output:

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



Run Instance»

Click the "Run Instance" button to view the online instance

Output:

Array ( [0] => b [1] => c [2] => d [3] => e )