Php array pointer, php Array

Source: Internet
Author: User

Php array pointer, php Array


Array pointer operation:

To move an array pointer:

Next () gets the value of the current element at the same time.

The value of the current element is obtained when Prev () is up.

Move End () to the last element unit to obtain the value of the last element.

Move Reset () to the first unit to obtain the value of the first element.

If the operation fails, false is returned.

Parameters are all arrays to be operated and are passed as references.

 

 

Obtain the information of the element pointed to by the pointer:

Key (); // obtain the element subscript pointed to by the current array pointer

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

Retrieve data only without moving the pointer

 

There is also a hybrid operation:

That is, you can obtain the information (key value) of the current pointer element and move the pointer at the same time.

Each (); obtain information about the current element (key and value information ),

.

 

 

 

Move pointer:

 

 

Sometimes we can use the each feature to traverse Arrays:

The loop structure should be used with each.

Condition: when each reaches the last element, false is returned.

 

 

 

List function:

 

List restrictions: it only applies to index arrays.

 

 

Traverse using list and each

 

 

However, after each traversal, the array pointer will not be reset by reset. You need to manually reset the array pointer.

 

 


Array pointer operation:

To move an array pointer:

Next () gets the value of the current element at the same time.

The value of the current element is obtained when Prev () is up.

Move End () to the last element unit to obtain the value of the last element.

Move Reset () to the first unit to obtain the value of the first element.

If the operation fails, false is returned.

Parameters are all arrays to be operated and are passed as references.

 

 

Obtain the information of the element pointed to by the pointer:

Key (); // obtain the element subscript pointed to by the current array pointer

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

Retrieve data only without moving the pointer

 

There is also a hybrid operation:

That is, you can obtain the information (key value) of the current pointer element and move the pointer at the same time.

Each (); obtain information about the current element (key and value information ),

.

 

 

 

Move pointer:

 

 

Sometimes we can use the each feature to traverse Arrays:

The loop structure should be used with each.

Condition: when each reaches the last element, false is returned.

 

 

 

List function:

 

List restrictions: it only applies to index arrays.

 

 

Traverse using list and each

 

 

However, after each traversal, the array pointer will not be reset by reset. You need to manually reset the array pointer.

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.