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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP prev() Function Usage and Example

PHP Array Function Manual

The prev() function moves the internal pointer of the array back one position

Syntax

prev ($array);

Definition and Usage

The prev() function returns the value of the array at the previous position pointed to by the internal array pointer, or FALSE if there are no other elements.

prev() and next() behave similarly, except that it moves the internal pointer back one position instead of forward one.

Parameter

Serial NumberParameters and Description
1

array(Required)

It specifies an array

Return Value

Returns the value of the previous element within the array, or FALSE if there are no more elements.

Online Example

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

Output Result:

foot

   PHP Array Function Manual