range函數可以用來創建一個包含指定范圍內元素的數組。其使用方法如下:
range(start, end, step)
示例如下:
$arr = range(1, 5);
print_r($arr);
// 輸出:Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )
$arr = range(1, 10, 2);
print_r($arr);
// 輸出:Array ( [0] => 1 [1] => 3 [2] => 5 [3] => 7 [4] => 9 )