如何从数组中删除索引

时间:2015-02-07 10:50:42

标签: php arrays wordpress indexing

我有以下数组:

Array
(
    [relation] => AND
    [0] => Array
        (
            [relation] => AND
            [0] => Array
                (
                    [key] => restaurant_country
                    [value] => India
                    [compare] => ==
                )

            [1] => Array
                (
                    [key] => restaurant_city
                    [value] => East Delhi - Noida
                    [compare] => ==
                )

        )

    [1] => Array
        (
            [relation] => OR
            [0] => Array
                (
                    [key] => restaurant_price_min
                    [value] => 100
                    [compare] => <=
                )

            [1] => Array
                (
                    [key] => restaurant_price_min
                    [value] => 500
                    [compare] => <=
                )

        )

)

我想从上面的数组中删除索引。例如,我想要以下数组而不是上面的数据。

Array
(
    [relation] => AND
    Array
        (
            [relation] => AND
            [0] => Array
                (
                    [key] => restaurant_country
                    [value] => India
                    [compare] => ==
                )

            [1] => Array
                (
                    [key] => restaurant_city
                    [value] => East Delhi - Noida
                    [compare] => ==
                )

        )

    Array
        (
            [relation] => OR
            [0] => Array
                (
                    [key] => restaurant_price_min
                    [value] => 100
                    [compare] => <=
                )

            [1] => Array
                (
                    [key] => restaurant_price_min
                    [value] => 500
                    [compare] => <=
                )

        )

)

我想要这种格式的数组,因为wordpress查询以这种方式运行。

我没有得到如何做到这一点。

请帮帮我。

2 个答案:

答案 0 :(得分:2)

你想要的数组是不可能的,因为每个数组都有它的键,你不能删除它。

答案 1 :(得分:1)

似乎是一个var_export显示器。 也许你试图用print_r来展示它?

即使3DR的答案是正确的,也是不可能的......