The What
Description
The array_pop
function does the following tasks:
- It checks if the variable is an array and it’s not empty. If no, it returns null.
- Copies the last element of out the array.
- It deletes the last element out of the array.
- Then it does a
reset
, which moves the array’s internal pointer to the first element in the array. - Then it returns the copied element.
Parameters
array_variable
- The array to be worked on by
array_pop
.
Return Values
It returns the last element’s value (not the key) when the array is not empty. Else it returns FALSE
when each of the variables passed into the instruction meet the checks listed above.
Show It in ActionBasic
Let’s see the array_pop
function in action. In this video, you will see how it works.
Keep It Simple, Stupid (KISS) - the best kiss you'll get in code.
Go DeepPro
In this video, you will go deeper into the instruction.
WhenPro
Also See
The following PHP constructs were mentioned in the code examples: