可能重复:
PHP remove the first index of an array and re-index
How to Remove Array Element and Then Re-Index Array?
$arr = array(1, 2, 3);
unset($arr[0]);
print_r($arr);
//Array ( [1] => 2 [2] => 3 )
调用的函数是什么,因此输出将是:
//Array ( [0] => 2 [1] => 3 )
答案 0 :(得分:3)
您想使用array_values
创建一个新数组:
$arr = array(1, 2, 3);
unset($arr[0]);
$arr = array_values($arr);
print_r($arr);
//Array ( [0] => 2 [1] => 3 )