PHP多维数组:删除外部数组,删除索引键和其余数组(以逗号分隔)

时间:2019-08-18 01:01:22

标签: php arrays multidimensional-array

我有多维数组。

  • 我要删除其外部数组和索引键。
  • 然后返回用逗号分隔的其余数组

以下代码给出了我想要的结果,但是通过使用其索引[0]仅返回一个数组。该代码来自Removing an outer array:

$new_array = $outer_array[0];
$new_array = reset($out_arr);

这是我的多维数组

$old_array = Array
(
    [0] => Array
        (
            [taxonomy] => updatable-category
            [field] => term_id
            [terms] => Array
                (
                    [0] => 136
                    [1] => 134
                    [2] => 135
                )

            [operator] => IN
        )

    [1] => Array
        (
            [taxonomy] => apps-category
            [field] => term_id
            [terms] => Array
                (
                    [0] => 126
                    [1] => 124
                    [2] => 125
                )

            [operator] => IN
        )

);

以下为必填结果。注意:这里返回的数组必须用逗号分隔

$new_array = Array
(
    [taxonomy] => updatable-category
    [field] => term_id
    [terms] => Array
        (
            [0] => 136
            [1] => 134
            [2] => 135
        )

    [operator] => IN
)
,
Array
(
    [taxonomy] => apps-category
    [field] => term_id
    [terms] => Array
        (
            [0] => 126
            [1] => 124
            [2] => 125
        )

    [operator] => IN
);

0 个答案:

没有答案