php - 重新排列数组键 php

标签 php arrays sorting

<分区>

我有这个数组:

Array
(
[15] =>     13.1

[16] =>     Mark one answer

[19] => You see a car on the hard shoulder of a motorway with a HELP pennant displayed. This means the driver is most likely to be

[20] => a disabled person first aid trained

[21] => a foreign visitor

[22] => a rescue patrol person

[25] => DES s15, HC r278);

如何让它从 0 开始对键进行排序? 得到这个:我知道有一个函数,但我的头很痛,排序函数不符合我的需要,因为它们重新排列值,我需要它们被保存。

 Array
(
[0] =>  13.1

[1] =>  Mark one answer

[2] => You see a car on the hard shoulder of a motorway with a HELP pennant displayed. This means the driver is most likely to be

[3] => a disabled person first aid trained

[4] => a foreign visitor

[5] => a rescue patrol person

[6] => DES s15, HC r278);

最佳答案

我认为您正在寻找 array_values

$arr = array_values($arr);

关于php - 重新排列数组键 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8797710/

相关文章:

php - jquery组合两个mysql值

php - json_decode返回一个空值,而不是一个数组

javascript - Array.splice() 是否可以通过在数组最后一个元素之外的索引处添加元素来创建稀疏数组?

php - Laravel 5 - Php artisan 语法错误

php - 拆分字符串中的第一个空格和最后一个空格并限制输出的大小 3

javascript - 按字符串值对数组进行排序

python reversed(list) 和 list.sort(reverse=True) 的区别

algorithm - 拓扑排序

php - 如何取消数组内的数组

arrays - mongodb,对象数组上的$sum