How can unset() be used to remove keys from an array in PHP?

To remove keys from an array in PHP, you can use the unset() function. This function allows you to unset a specific key from an array, effectively removing it. To use unset(), you simply need to pass the key you want to remove as an argument to the function.

// Sample array
$fruits = array("apple" => "red", "banana" => "yellow", "orange" => "orange");

// Remove the key "banana" from the array
unset($fruits["banana"]);

// Output the modified array
print_r($fruits);