No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

range

(PHP 4, PHP 5, PHP 7)

rangeCreate an array containing a range of elements

Description

range ( mixed $start , mixed $end [, number $step = 1 ] ) : array

Create an array containing a range of elements.

PHP: range - Manual Home of Manuel PHP  Contents Haut

Parameters

start

First value of the sequence.

end

The sequence is ended upon reaching the end value.

step

If a step value is given, it will be used as the increment between elements in the sequence. step should be given as a positive number. If not specified, step will default to 1.

PHP: range - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns an array of elements from start to end, inclusive.

PHP: range - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 range() examples

<?php
// array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
foreach (range(012) as $number) {
    echo 
$number;
}

// The step parameter
// array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
foreach (range(010010) as $number) {
    echo 
$number;
}

// Usage of character sequences
// array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
foreach (range('a''i') as $letter) {
    echo 
$letter;
}
// array('c', 'b', 'a');
foreach (range('c''a') as $letter) {
    echo 
$letter;
}
?>

PHP: range - Manual Home of Manuel PHP  Contents Haut

Notes

Note:

Character sequence values are limited to a length of one. If a length greater than one is entered, only the first character is used.

PHP: range - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function
Error Infobrol

Can not display this page of the Infobrol website

Type of error (18-01)

Unknown format specifier "&"

Please try again in a few minutes…

Return to the home page




Steph