PHP

PHP Menu

PHP

range() Function - Definition, Syntax, Parameters, Examples

Definition

The range() function creates an array containing a range of elements.

Syntax

range(low, high, step)

Parameters

Parameter Description
low Required. Specifies the lowest value of the array.
high Required. Specifies the highest value of the array.
step Optional. Specifies the increment used in the range. Default is 1.

Example

<?php
// Example 1 $myNumbers = range(0, 6); print_r($myNumbers); echo "<br>";
// Example 2 $myNumbers = range(0, 20, 2); print_r($myNumbers); echo "<br>";

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods