PHP Array function sequence prev ()-Moves the internal pointer of an array to the position of the previous element and returns the element value _php tips

Source: Internet
Author: User
Tags prev
Prev () Definition and usage
The prev () function moves the pointer to the current element to the position of the previous element and returns the element value.

If the internal pointer already exceeds the first element of the array, the function returns FALSE.

Grammar
Prev (array) parameter description
Array required. Specify the array to use.

Description
The behavior of Prev () and Next () is similar, but it pours the internal pointer back one rather than forward.

Note: If the array contains empty cells, or if the cell value is 0, the function encounters these cells and returns FALSE. To properly traverse an array that may contain empty cells or a cell value of 0, see the each () function.

Example
Copy Code code as follows:

<?php
$people = Array ("Peter", "Joe", "Glenn", "Cleveland");

Echo current ($people). "<br/>";
Echo Next ($people). "<br/>";
Echo prev ($people);
?>

Output:

Peter
Joe
Peter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.