Computer >> Computer tutorials >  >> Programming >> PHP

prev() function in PHP


The prev() function rewinds the internal array pointer. It outputs the previous element in the array.

Syntax

prev(arr)

Parameters

  • arr − The specified array. Required.

Return

The pos() function returns the value of the previous element in an array.

Example

The following is an example −

<?php
   $arr = array("one", "two");
   echo pos($arr);
   echo next($arr);
   echo prev($arr);
?>

Output

one
two
one