PHP多维数组-将值复制到不同的列键

问题描述 投票:-2回答:2

我对此多维数据集有问题,我需要将值复制到其他列键。

这是数组。

数组([0] =>数组([0] => item_type[1] => product_id[2] => sku[3] =>名称[4] =>基本图片[5] => new_name)[1] =>数组([0] =>产品[1] => 12629[2] => 5102id.22755[3] =>产品名称1[4] => CC22755e.jpg[5] =>)[2] =>数组([0] =>选项[1] => 12629[2] => 22755.Red[3] => [选择颜色] =红色[4] =>[5] =>)[3] =>数组([0] =>选项[1] => 12629[2] => 22755.Orange[3] => [选择颜色] =橙色[4] =>[5] =>)[5] =>数组([0] =>产品[1] => 12631[2] => 0829id.23122[3] =>产品名称2[4] => CC23122b.jpg[5] =>)[6] =>数组([0] =>选项[1] => 12631[2] => 23122.黑色[4] => [选择颜色] =黑色[5] =>[6] =>))

想要此输出,在多维数组中可以吗?

数组([0] =>数组([0] => item_type[1] => product_id[2] => sku[3] =>名称[4] =>基本图片[5] => new_name)[1] =>数组([0] =>产品[1] => 12629[2] => 5102id.22755[3] =>产品名称1[4] => CC22755e.jpg[5] =>)[2] =>数组([0] =>选项[1] => 12629[2] => 22755.Red[3] => [选择颜色] =红色[4] =>[5] => **产品名称1 **)[3] =>数组([0] =>选项[1] => 12629[2] => 22755.Orange[3] => [选择颜色] =橙色[4] =>[5] => **产品名称1 **)[5] =>数组([0] =>产品[1] => 12631[2] => 0829id.23122[3] =>产品名称2[4] => CC23122b.jpg[5] =>)[6] =>数组([0] =>选项[1] => 12631[2] => 23122.黑色[3] => [选择颜色] =黑色[4] =>[5] => **产品名称2 **))

希望有可能...

php arrays multidimensional-array
2个回答
0
投票

您想做的是这个?

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

0
投票

您的问题尚不清楚,但我认为是关于:

$name = $arr[0][3];
$arr[0][5] = $name;
© www.soinside.com 2019 - 2024. All rights reserved.