What potential pitfalls should be considered when using unset to delete elements from an array in PHP?

When using unset to delete elements from an array in PHP, it's important to consider the potential pitfalls such as reindexing the array keys and unintentionally removing other elements. To avoid these issues, it's recommended to use array_splice instead of unset to remove elements from an array while maintaining the original keys.

// Example of using array_splice to remove elements from an array without reindexing keys
$array = ['a', 'b', 'c', 'd', 'e'];

// Remove element at index 2
array_splice($array, 2, 1);

print_r($array);