PHP reset() Function

PHP reset() Function

The reset() function in PHP is used to set the internal pointer of an array to its first element and returns the value of the first array element.

Syntax

reset ( array &$array ) 

Parameter

array(required)- This parameter represents the input array.

 Return

This parameter returns the value of the first element of the specified array or returns FALSE if the array is empty.

Example 1

 

Output

The pointer of the array is at mango

Example 2

 

Output

The pointer of the array is at pear
The pointer of the array is at mango 

Example 3

 

Output

The pointer of the array is at 'bike'
The pointer of the array is at 'cycle'
The pointer of the array is at 'bike'
The pointer of the array is at 'cycle'
The pointer of the array is at 'cycle'