• PHP Video Tutorials

PHP - Function previous()



Syntax

prev ( $array );

Definition and Usage

The prev() function returns the array value in the previous place that's pointed to by the internal array pointer, or FALSE if there are no more elements.

Parameters

Sr.No Parameter & Description
1

array(Required)

It specifies an array

Return Value

It returns the previous element in an array.

Example

Try out following example −

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

This will produce the following result −

foot 
php_function_reference.htm
Advertisements