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

range() function in PHP

王林
Release: 2023-08-25 12:04:02
forward
1149 people have browsed it

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)
Copy after login

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);
?>
Copy after login

Output

The following is the output-

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

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

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template