Can you delete an element from an array using its index in PHP?

Yes, you can delete an element from an array using its index in PHP by using the unset() function. This function removes the element at a specific index from the array, shifting all subsequent elements to the left to fill the gap.

$array = [1, 2, 3, 4, 5];
$index = 2; // Index of the element to delete
unset($array[$index]);
print_r($array); // Output: [1, 2, 4, 5]