PHP: re-index array after removing an element

php 的陣列中移除一個元素後,如何把 index 重排(意即被移除的元素之後的所有元素的 index 往前移)

unset($foo[5]); // remove item at index 5
$foo2 = array_values($foo); // 'reindex' array