How can you delete a specific element from an array in PHP?
To delete a specific element from an array in PHP, you can use the unset() function. This function removes a specified element from an array based on its key. You need to know the key of the element you want to delete in order to use unset() effectively.
$array = [1, 2, 3, 4, 5];
$keyToDelete = 2; // Index of the element to delete
unset($array[$keyToDelete]);
print_r($array);