PHP头条
热点:

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


range() 函数

【功能】
         该函数将返回数组中从low到high的单元,
         包含他们本身,如果low>high,则序列从high到low
【使用范围】
         >=3.0.8、php4、php5
【使用】
         range(first,second,step)
         first/必需/规定数组元素最小值
         second/必需/规定数组元素最大值
         step/可选/规定元素之间的间隔/默认为1/该参数是php5之后加的
【示例】
[php]
<?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的笔记

www.phpzy.comtrue/phprm/16519.htmlTechArticlephp-Arrays函数-range-建立一个包含指定范围单元的数组 range() 函数 【功能】 该函数将返回数组中从low到high的单元, 包含他们本身,如果lowhigh,则序列从high到low 【使用范围】 =3.0.8、ph...

相关文章

    暂无相关文章

PHP之友评论

今天推荐