The prev() function is an inbuilt function in PHP.
- It is used to return the immediate previous element from an array of the element which is currently pointed by the internal pointer.
- We have already discussed current() function in PHP.
- The current() function is used to return the value of the element which is currently pointed by the internal pointer whereas the prev() function decrements or make the internal pointer to point to the previous element of the currently pointed element.
Parameters: This function accepts a single parameter $array. It is the array of which we want to find the current element.
Return Value: It returns the value of the element in the array which is just before the element which the internal pointer is currently pointing to. If the array is empty then the prev() function returns FALSE.
Below programs illustrate the prev() function in PHP:
Ram Shita Ram
a 2 z 2
This article is attributed to GeeksforGeeks.org