
- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Environment Setup
- PHP - Syntax Overview
- PHP - Variable Types
- PHP - Constants
- PHP - Operator Types
- PHP - Decision Making
- PHP - Loop Types
- PHP - Arrays
- PHP - Strings
- PHP - Web Concepts
- PHP - GET & POST
- PHP - File Inclusion
- PHP - Files & I/O
- PHP - Functions
- PHP - Cookies
- PHP - Sessions
- PHP - Sending Emails
- PHP - File Uploading
- PHP - Coding Standard
- Advanced PHP
- PHP - Predefined Variables
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Bugs Debugging
- PHP - Date & Time
- PHP & MySQL
- PHP & AJAX
- PHP & XML
- PHP - Object Oriented
- PHP - For C Developers
- PHP - For PERL Developers
- PHP Form Examples
- PHP - Form Introduction
- PHP - Validation Example
- PHP - Complete Form
- PHP login Examples
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP AJAX Examples
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML Example
- PHP - XML Introduction
- PHP - Simple XML
- PHP - Simple XML GET
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Frame Works
- PHP - Frame Works
- PHP - Core PHP vs Frame Works
- PHP Design Patterns
- PHP - Design Patterns
- PHP Function Reference
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
PHP - Function range()
Syntax
range ( $low, $high [, $step] );
Definition and Usage
This function returns an array of elements from low to high, inclusive. If low > high, the sequence will be from high to low.
Parameters
Sr.No | Parameter & Description |
---|---|
1 |
low(Required) This is a lower range of the array |
2 |
high(Required) This is a upper range of the array |
3 |
step(Optional) Steps to increase array element. By default it is 1 |
Return Value
It returns array of elements.
Example
Try out following example −
<?php foreach (range(0, 6) as $number) { echo "$number, "; } print "\n"; foreach (range(0, 100, 10) as $number) { echo "$number, "; } print "\n"; foreach (range('a', 'c') as $letter) { echo "$letter, "; } print "\n"; foreach (range('f', 'a') as $letter) { echo "$letter, "; } print "\n"; ?>
This will produce the following result −
0, 1, 2, 3, 4, 5, 6, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 a, b, c, f,e,d,c, b, a
php_function_reference.htm
Advertisements