重置数组键

时间:2015-12-31 09:39:55

标签: php

我有以下数组,键0,1,2,3,4

Array
(
[media_list] => Array
    (
        [0] => Array
            (
                [media_id] => c36ca1a05136461ba3642f943b3ac447
                [title] => Eat This: Best of 2015 31 DEC
                [description] => Enjoy this week's Eat This episode, 
                [thumbnail_url] => zbr.120x66.jpeg
                [duration] => 239867
            )

        [1] => Array
            (
                [media_id] => 3b9179b13a7943f0818e82ff7970a8ba
                [title] => Eat This: Encore - Crossroads Bake Shop
                [description] => Chuck visits the Crossroads Bake Shop 
                [thumbnail_url] => ZMw.120x66.jpeg
                [duration] => 253367
            )

        [2] => Array
            (
                [media_id] => e2f440d4a6314027b967f414e6692204
                [title] => Eat This:Robin's Nest
                [description] => 
                [thumbnail_url] => 84-.120x66.jpeg
                [duration] => 312733
            )

        [3] => Array
            (
                [media_id] => 0fb7fff38ced4dfc8061bf1528902384
                [title] => Eat This: Weinrich's Bakery
                [description] => The Philadelphia area is known for buttercakes,
                [thumbnail_url] => 0P_.120x66.jpeg
                [duration] => 274133
            )

        [4] => Array
            (
                [media_id] => 76ac830d33f34a7c97c725e341246376
                [title] => Encore - Eat This: Heritage Turkeys
                [description] => Eat This stops by Longview Farm Market in Collegeville to see
                [thumbnail_url] => 83x.120x66.jpeg
                [duration] => 262633
            )

       )

)

如果我从这个数组中移除(取消设置)任何键(比如我删除了键0),那么数组看起来像 -

Array
(
     [1] => Array
        (
            [media_id] => 3b9179b13a7943f0818e82ff7970a8ba
            [title] => Eat This: Encore - Crossroads Bake Shop
            [description] => Chuck visits the Crossroads Bake Shop 
            [thumbnail_url] => ZMw.120x66.jpeg
            [duration] => 253367
        )
    [2] => Array
        (
        [media_id] => e2f440d4a6314027b967f414e6692204
        [title] => Eat This:Robin's Nest
        [description] => 
        [thumbnail_url] => 120x66.jpeg
        [duration] => 312733
    )

[3] => Array
    (
        [media_id] => 0fb7fff38ced4dfc8061bf1528902384
        [title] => Eat This: Weinrich's Bakery
        [description] => The Philadelphia area is known for   buttercakes
        [thumbnail_url] => P_.120x66.jpeg
        [duration] => 274133
    )

[4] => Array
    (
        [media_id] => 76ac830d33f34a7c97c725e341246376
        [title] => Encore - Eat This: Heritage Turkeys
        [description] => Eat This stops by Longview Farm Market in     Collegeville to see how their resident
            [thumbnail_url] => 83x.120x66.jpeg
            [duration] => 262633
    )
)

数组键从0,1,2,3,4更改了1,2,3,4 我希望我的数组键从0,1,3,4,5开始,依此类推。

1 个答案:

答案 0 :(得分:1)

$array = array_values($array);
相关问题