Thursday, 25 September 2014

prev in PHP

PHP prev() function is used to move internal pointer of an array to previous element, and returns it.
PHP prev() function returns value of previous element from array on success, or else FALSE if there are no more elements.

Syntax:


prev(array)
array : Required. Specifies the array to use.

Example:


<?php
$daysarr = array( "Sunday","Monday","Tuesday","Wednesday","Thursday" );
echo current($daysarr) . " < br />";
echo next($daysarr) . " < br />";
echo prev($daysarr);
?>

Output will be:


Sunday
Monday
Sunday

0 comments:

Post a Comment