Home  >  Article  >  Backend Development  >  range() function in PHP

range() function in PHP

王林
王林forward
2023-08-25 12:01:061037browse

range() function in PHP

range() function creates an array containing a range of elements. It returns the elements from start to end.

Syntax

range(start, end, step)

Parameters

  • start - first value

  • end - the last value

  • step - the increment in the range

returned Value

range() function returns the elements from start to end.

Example

The following is an example-

Live Demo

<?php
$number = range(0,12,3);
print_r ($number);
?>

Output

The following is the output-

Array
(
[0] => 0
[1] => 3
[2] => 6
[3] => 9
[4] => 12
)

The above is the detailed content of range() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete