PHP 删除数组键
PHP remove array keys
我有
Array ( [0] => 2088 [1] => 2087 [2] => 2091 [3] => 2083 [4] => 2086 [5] => 2085 [6] => 2084 [7] => 2092 [8] => 2089 [10] => 2122 [11] => 2122 )
如你所见,我没有数组键号 9
我怎样才能将其他键向下移动 [9] => 2122 [10] => 2122?
谢谢
您可以使用 array_values
来完成
$array = array ( 0 => 2088, 1 => 2087, 2 => 2091, 3 => 2083, 4 => 2086, 5 => 2085, 6 => 2084, 7 => 2092, 8 => 2089, 10 => 2122, 11 => 2122 );
$newarray = array_values($array);
var_dump($newarray);
我有
Array ( [0] => 2088 [1] => 2087 [2] => 2091 [3] => 2083 [4] => 2086 [5] => 2085 [6] => 2084 [7] => 2092 [8] => 2089 [10] => 2122 [11] => 2122 )
如你所见,我没有数组键号 9
我怎样才能将其他键向下移动 [9] => 2122 [10] => 2122?
谢谢
您可以使用 array_values
来完成
$array = array ( 0 => 2088, 1 => 2087, 2 => 2091, 3 => 2083, 4 => 2086, 5 => 2085, 6 => 2084, 7 => 2092, 8 => 2089, 10 => 2122, 11 => 2122 );
$newarray = array_values($array);
var_dump($newarray);