Method One:
Output
Output 8
Method Two:
Output
Output 8
Method Three:
Output
Array ([0] = 8)
The second method has the disadvantage that the Array_pop () function will "take out" the last number of the original data, that is, the meaning of the cut, the original data will no longer have the last value.
Such as:
Output:
Array ([0] = 1 [1] = 2 [2] = 4 [3] = 6)
These are the built-in functions in PHP, and we can actually get the last element in the PHP array by some of our own methods.
Of course, if the built-in method can be implemented, we try to use PHP's built-in functions, because in terms of efficiency or time, the built-in method is the most efficient, but in the process of development, if we do not know the existence of this method or do not remember this method, We can also write our own method of function according to our own logic.