Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Let's hope our todo list is getting smaller because we're getting stuff done, so we need to be able to remove things from our list. In this video we'll look at three ways php gives us to remove an element from an array.
Documentation
array_shift: Shift an element off the beginning of array.
array_pop: Pop the element off the end of array
unset: Unset a given variable (works on more than array values)
Keep in Mind
unset($array); will remove your entire array.
Everytime you call array_shift you remove an element:
$removed = array_shift($learn);
echo 'you removed ' . array_shift($learn);
Would remove two elements from the array.
Additional Option for Modifying an Array
Array Splice: remove a portion of the array and replace it with something else
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up