Home  >  Article  >  Backend Development  >  php-Arrays function-range-creates an array containing cells in a specified range_PHP tutorial

php-Arrays function-range-creates an array containing cells in a specified range_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:51:331030browse

range() function

【Function】
This function will return the cells from low to high in the array,
Including themselves, if low>high, the sequence goes from high to low
【Scope of use】
            >=3.0.8, php4, php5
【Use】
​​​​range(first,second,step)
            first/required/specifies the minimum value of array elements
          second/required/specifies the maximum value of array elements
step/optional/specifies the interval between elements/defaults to 1/this parameter was added after php5
【Example】
[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
)
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478195.htmlTechArticlerange() function [Function] This function will return the cells from low to high in the array, including themselves, If lowhigh, the sequence is from high to low [Usage scope] =3.0.8, php4, php5...
Statement:
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