Name
prev
Synopsis
mixed prev(array array
)
Moves the internal pointer to the element before its current
location and returns the value of the element to which the internal
pointer is now set. If the internal pointer is already set to the
first element in the array, returns false
. Be careful when iterating over an
array using this function—if an array has an empty element or an
element with a key value of 0
, a
value equivalent to false
is
returned, causing the loop to end. If an array might contain empty
elements or an element with a key of 0
, use the each()
function instead of a loop with
prev()
.
Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.