PHP Array Pointers

Source: Internet
Author: User


Operation of Array pointers:

To move an array pointer operation:

Next () will also get the value of the current element down.

Prev () will also get the value of the current element.

End () moves to the last element cell to get the value of the last element

Reset () moves to the first cell to get the value of the first element.

returns False if the move is unsuccessful .

Parameters are arrays that require manipulation, and are reference passes.

Gets the information for the element pointed to by the pointer:

Key ();//Gets the element subscript that the current array pointer points to

Current ();//Gets the element pointed to by an array pointer

get data only do not move pointer

There is also a mixed operation:

that is, you can get information about the current pointer element (the key value) or you can move the pointer at the same time.

each (); Gets information about the current element (key and value information),

A.

Move the pointer:

we can sometimes use each of the features to achieve the purpose of iterating over an array:

The loop structure should be used with each completion.

mate Condition:when each is to the last element, it returns false.

List function:

List restriction: only works on indexed arrays.

using list and each to complete the traversal

but using the play each traversal after the array pointer is not reset resets the reset and needs to be reset manually.


Operation of Array pointers:

To move an array pointer operation:

Next () will also get the value of the current element down.

Prev () will also get the value of the current element.

End () moves to the last element cell to get the value of the last element

Reset () moves to the first cell to get the value of the first element.

returns False if the move is unsuccessful .

Parameters are arrays that require manipulation, and are reference passes.

Gets the information for the element pointed to by the pointer:

Key ();//Gets the element subscript that the current array pointer points to

Current ();//Gets the element pointed to by an array pointer

get data only do not move pointer

There is also a mixed operation:

that is, you can get information about the current pointer element (the key value) or you can move the pointer at the same time.

each (); Gets information about the current element (key and value information),

A.

Move the pointer:

we can sometimes use each of the features to achieve the purpose of iterating over an array:

The loop structure should be used with each completion.

mate Condition:when each is to the last element, it returns false.

List function:

List restriction: only works on indexed arrays.

using list and each to complete the traversal

but using the play each traversal after the array pointer is not reset resets the reset and needs to be reset manually.

PHP Array Pointers

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.