In php, the end () function directs the internal pointer of the array to the last element and returns the value of this element. The current () function returns the current element (unit, these two functions return the first element of the array and the last element of the array. let's take a look at the usage of these two functions.
What are the functions of php end () and current () functions?
In php, the end () function directs the internal pointer of the array to the last element and returns the value of this element. The current () function returns the current element (unit, these two functions return the first element of the array and the last element of the array. let's take a look at the usage of these two functions.
End () function
The end () function points the pointer inside the array to the last element. if it succeeds, the value of this element is returned;
Example 1
Use the end () function to return the last element of the array. the code is as follows:
Code running result:
Current () function
The current () function returns the current element (unit) in the array ). Each array has an internal pointer pointing to its "current" element, initially pointing to the first element inserted into the array.
PS: If an empty element or element has no value, the function returns FALSE.
Example 2
Use the current () function to return the first element of the array. the code is as follows:
Code running result:
Example 3
Use the current () and end () functions to output the values of the current element and the last element in the array. the code is as follows:
";echo end($people);?>
Code running result:
[Recommended related articles]
Php array function current () definition and usage
Php operations on array functions current, next, and reset function Usage examples
The above is a detailed description of the php end () function and current () function usage instance. For more information, see other related articles in the first PHP community!