Home > php教程 > php手册 > php-Arrays函数-range-建立一个包含指定范围单元的数组

php-Arrays函数-range-建立一个包含指定范围单元的数组

WBOY
Release: 2016-06-13 10:49:44
Original
1667 people have browsed it

range() 函数

【功能】
         该函数将返回数组中从low到high的单元,
         包含他们本身,如果low>high,则序列从high到low
【使用范围】
         >=3.0.8、php4、php5
【使用】
         range(first,second,step)
         first/必需/规定数组元素最小值
         second/必需/规定数组元素最大值
         step/可选/规定元素之间的间隔/默认为1/该参数是php5之后加的
【示例】
[php]
        print_r( range( 0, 5 ) ); 
        print_r( range( 5, 1 ) ); 
        print_r( range( 0, 5, 2 ) ); 
        print_r( range( 0, 5, 3) ); 
/*
Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 4
    [5] => 5
)
Array
(
    [0] => 5
    [1] => 4
    [2] => 3
    [3] => 2
    [4] => 1
)
Array
(
    [0] => 0
    [1] => 2
    [2] => 4
)
Array
(
    [0] => 0
    [1] => 3
)
*/ 

 


摘自 zuodefeng的笔记

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template