English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP reset() Function Usage and Example

PHP Array Function Manual

The reset() function points the internal pointer of the array to the first element

Syntax

reset(array $array);

Definition and Usage

The reset() function moves the internal pointer of the array back to the first element and returns the value of the first array element; if the array is empty, it returns FALSE.

Parameter

Serial NumberParameters and Description
1

array(Required)

It specifies an array

Return Value

Returns the first element of the array.

Online Example

<?php
   $input = array('foot', 'bike', 'car', 'plane');
   $mode = end($input);
   print "$mode <br />";
   
   $mode = reset($input);
   print "$mode <br />";
   
   $mode = current($input);
   print "$mode <br />";
?>
Test and See‹/›

Output Result

plane
foot
foot

   PHP Array Function Manual