【问题标题】:rearrange array keys php重新排列数组键php
【发布时间】:2012-01-10 02:03:32
【问题描述】:

我有这个数组:

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);

【问题讨论】:

    标签: php arrays sorting


    【解决方案1】:

    我想你在找array_values

    $arr = array_values($arr);

    【讨论】:

    • :) 当我知道这很简单并且不得不来这里询问时,我讨厌一个小时。非常感谢。
    • 看起来也应用了trim =) array_map('trim', ...) 达到最大值。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 2015-04-03
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多