How can you delete an element in an array by using its key in PHP?

To delete an element in an array by using its key in PHP, you can use the `unset()` function. This function removes the element with the specified key from the array. After unsetting the element, the array will be reindexed automatically.

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

// Delete the element with key 'banana'
unset($fruits['banana']);

// Output the updated array
print_r($fruits);
?>