Function prototype: range(start, end, scan):
Parameter meaning:
start: counting starts from start. The default is to start from 0. For example, range (5) is equivalent to range (0, 5);
end: the technology ends at end, but does not include end. For example: range (0, 5) is [0, 1, 2, 3 , 4] No 5
scan: The distance between each jump, the default is 1. For example: range(0, 5) is equivalent to range(0, 5, 1)
Example
>>> range(5) #Represents from 0 to 5 (excluding 5)
[0, 1, 2, 3, 4]
>>> range(0,5) #Represents from 0 to 5 (excluding 5)
[0, 1, 2, 3, 4 ]
>>> range(1,5) #Represents from 1 to 5 (excluding 5)
[1, 2, 3, 4]
>>> range( 1,5,2) # stands for from 1 to 5, with an interval of 2 (excluding 5)
[1, 3]
The above is the detailed content of Introduction to the usage of range. For more information, please follow other related articles on the PHP Chinese website!