You can also use array_reverse to reset array indexes without losing the order of the values. For example when you use unset() to delete values from an array, the value gets deleted but you end up with a missing index:
$array[0] = 'record1';
$array[9] = 'record2';
$array[15] = 'record3';
Just use:
$array = array_reverse(array_reverse($array));
And your indexes get rearranged:
$array[0] = 'record1';
$array[1] = 'record2';
$array[2] = 'record3';