function reindex_array_after_removal(array $array): array { // array_values() re-indexes the array numerically, starting from 0. // It discards string keys and re-indexes numeric keys. return array_values($array); } $items = ['apple', 'banana', 'cherry', 'date']; unset($items[1]); // Remove 'banana' // The array currently has non-consecutive numeric keys: // var_dump($items); // [0 => 'apple', 2 => 'cherry', 3 => 'date'] // Example usage: // $reindexedItems = reindex_array_after_removal($items); // var_dump($reindexedItems); // ['apple', 'cherry', 'date']