How can the issue of losing the index values be addressed when using array_shift in PHP?

When using array_shift in PHP, the issue of losing the index values can be addressed by using array_values() function after removing an element from the array. This function re-indexes the array starting from index 0.

$array = [1, 2, 3, 4, 5];
array_shift($array);
$array = array_values($array);
print_r($array);