调整数组中的键

时间:2013-07-20 14:20:42

标签: php arrays key

例如,我有以下数组:

$arr[0] = "1"
$arr[7] = "p"
$arr[10] = "c"
$arr[12] = 'k"

如何将其转换为:

$arr[0] = "1"
$arr[1] = "p"
$arr[2] = "c"
$arr[3] = 'k"

1 个答案:

答案 0 :(得分:1)

像这样:

$arr = array_values($arr);

http://www.php.net/manual/en/function.array-values.php