Concept
How does unset() remove elements from a PHP array?
ComputerScienceOne / Removing Elements
"You can remove elements from an array using the unset() function. This function only removes the element from the array, it does not shift other elements down to fill in the unused index.\n\n$arr = array(10, 20, 30);\n\nunset($arr[1]);\n\nprint_r($arr);\n\nThis example would result in the following.\n\nArray ( [0] => 10 [2] => 30 )\n\nFurther, you can use unset() to destroy all elements in the array."
Related Ideas
- What does unset($arr) do to an array?ComputerScienceOne · Using Arrays in Functions
- Can PHP array indices be non-contiguous?ComputerScienceOne · Strings as Indices
- Which PHP functions return an array’s keys and values?ComputerScienceOne · Useful Functions
- How can you print the contents of a PHP array in a readable format?ComputerScienceOne · Useful Functions
- How can you iterate over indexed and associative arrays in PHP?ComputerScienceOne · Iteration
- How can you count the elements in a PHP array?ComputerScienceOne · Useful Functions
- How do you create and index arrays in PHP?ComputerScienceOne · Creating Arrays
- How can you iterate through an array using foreach?ComputerScienceOne · Adding Elements