将多维关联数组转换为索引数组

时间:2017-02-28 13:34:15

标签: php arrays multidimensional-array

我有多维数组结果,内部有许多数组(关联数组),我想将内部数组替换为索引数组 原始数组结果如下:

Data Saved: Array
(
    [0] => Array
        (
            [fullname] => john
            [ServiceDescAR] => description
            [user_id] => 13
            [pos] => 29.958040,30.915489
            [icon] => http://maps.google.com/mapfiles/ms/icons/green.png
            [distance] => 0.00460411726624673
        )

    [1] => Array
        (
            [fullname] => angel
            [ServiceDescAR] => description
            [user_id] => 11
            [pos] => 29.958042,30.915478
            [icon] => http://maps.google.com/mapfiles/ms/icons/green.png
            [distance] => 0.005705603509640217
        )

)

我希望替换所有要编制索引的键,它将是这样的 该怎么做

Data Saved: Array
(
    [0] => Array
        (
            [1] => john
            [2] => description 
            [3] => 13
            [4] => 29.958040,30.915489
            [5] => http://maps.google.com/mapfiles/ms/icons/green.png
            [6] => 0.00460411726624673
        )

    [1] => Array
        (
            [1] => angel
            [2] => description 
            [3] => 11
            [4] => 29.958042,30.915478
            [5] => http://maps.google.com/mapfiles/ms/icons/green.png
            [6] => 0.005705603509640217
        )

)

1 个答案:

答案 0 :(得分:3)

您可以使用array_values从数组中提取所有值(不使用键):

$result = array_map('array_values', $inputArray);

生成的内部数组索引将从零开始。