PHP Многомерный массив - скопируйте значение в другой ключ столбца - PullRequest
0 голосов
/ 29 мая 2020

У меня проблема с этим многомерным, мне нужно скопировать значение в другой ключ столбца ..

вот массив.

Array
(
    [0] => Array
        (
            [0] => item_type
            [1] => product_id
            [2] => sku
            [3] => name
            [4] => baseimage
            [5] => new_name
        )

    [1] => Array
        (
            [0] => product
            [1] => 12629
            [2] => 5102id.22755
            [3] => product name 1
            [4] => CC22755e.jpg
            [5] => 
        )

    [2] => Array
        (
            [0] => option
            [1] => 12629
            [2] => 22755.Red
            [3] => [Select Color] = Red
            [4] =>
            [5] => 

        )

    [3] => Array
        (
            [0] => option
            [1] => 12629
            [2] => 22755.Orange
            [3] => [Select Color] = Orange
            [4] => 
            [5] => 
        )



    [5] => Array
        (
            [0] => product
            [1] => 12631
            [2] => 0829id.23122
            [3] => product name 2
            [4] => CC23122b.jpg
            [5] =>
        )

    [6] => Array
        (
            [0] => option
            [1] => 12631
            [2] => 23122.Black
            [4] => [Select Color] = Black
            [5] => 
            [6] => 
        )

)

Хотите этот вывод, возможно ли это в Многомерный массив?

Array
(
    [0] => Array
        (
            [0] => item_type
            [1] => product_id
            [2] => sku
            [3] => name
            [4] => baseimage
            [5] => new_name
        )

    [1] => Array
        (
            [0] => product
            [1] => 12629
            [2] => 5102id.22755
            [3] => product name 1
            [4] => CC22755e.jpg
            [5] => 
        )

    [2] => Array
        (
            [0] => option
            [1] => 12629
            [2] => 22755.Red
            [3] => [Select Color] = Red
            [4] =>
            [5] => **product name 1**

        )

    [3] => Array
        (
            [0] => option
            [1] => 12629
            [2] => 22755.Orange
            [3] => [Select Color] = Orange
            [4] => 
            [5] => **product name 1**
        )



    [5] => Array
        (
            [0] => product
            [1] => 12631
            [2] => 0829id.23122
            [3] => product name 2
            [4] => CC23122b.jpg
            [5] => 
        )

    [6] => Array
        (
            [0] => option
            [1] => 12631
            [2] => 23122.Black
            [3] => [Select Color] = Black
            [4] => 
            [5] => **product name 2**
        )

)

Надеюсь, это возможно ...

Ответы [ 2 ]

0 голосов
/ 29 мая 2020

Ваш вопрос непонятен, но я думаю, что он о:

$name = $arr[0][3];
$arr[0][5] = $name;
0 голосов
/ 29 мая 2020

Что вы хотите сделать?

$array[5][3] = $array[3][5]
...