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.