Skip to content
PHP Logo

How can the PHP

Issue: How to use the PHP unset() function to remove a specific element from an array. Solution: To remove a specific element from an array in PHP, you can use the unset() function by passing the key of the element you want to remove as a parameter. This will unset the element from the array and shift any subsequent elements to fill the gap.

php
<?php
$array = array("a" => 1, "b" => 2, "c" => 3);
unset($array["b"]);
print_r($array);
?>