Bifalgorithm post · Computer science one · Removing Elements
How does unset() remove elements from a PHP array?
How does unset() remove elements from a PHP array? (Computer science one · Removing Elements) — "You can remove elements from an array using the unset() functi…
Ideas in this flowchart
- Removing array elements with unset()
- unset() removes an element from an array
- Removing an element does not shift the other elements
- Example of removing an array element
- $arr = array(10, 20, 30);
- unset($arr[1]);
- print_r($arr); displays the resulting array
- The result is Array ( [0] => 10 [2] => 30 )
- unset() can also destroy all elements in the array