PHP prev array function

Last Updated: February 21, 2022

prev – Move internal pointer to the previous element of the array

Syntax

 prev(array|object &$array): mixed

Supports (PHP 4 , PHP 5, PHP 7, PHP 8)

Parameters

Parameter Description
array input array

Return Value

Return the value of the array of the previous location. If no element is found it will return false

Example

$array1 = array('a', 'c', 'b', 'D', 'E', 'F');

next($array1); //  'c';
echo prev($array1);    // 'a';

Output

a

Test