What is the function of unset() in PHP and how is it used to remove elements from an array?
The unset() function in PHP is used to remove a specific element from an array. It can be used to unset a single element or multiple elements from an array. To remove an element from an array using unset(), you need to specify the key of the element you want to remove.
// Define an array
$fruits = array("apple", "banana", "orange", "kiwi");
// Remove the element with key 1 (banana) from the array
unset($fruits[1]);
// Print the modified array
print_r($fruits);