there is now a two-dimensional array in the following format:
Array
(
[0] => Array
(
[id] => 38
[goods_id] => 77426
[model_name] =>
[model_sub_name] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
)
[goods_stock] => Array
(
[0] => 321
)
[curr_price] => Array
(
[0] => 99
)
[goods_weight] => Array
(
[0] => 280
)
)
[1] => Array
(
[id] => 39
[goods_id] => 77426
[model_name] =>
[model_sub_name] => Array
(
[0] => 32A
[1] => 34A
[2] => 36A
[3] => 32B
[4] => 34B
[5] => 36B
[6] => 38B
[7] => 34C
[8] => 36C
[9] => 38C
[10] => 40C
[11] =>
)
[goods_stock] => Array
(
[0] => 321
)
[curr_price] => Array
(
[0] => 99
)
[goods_weight] => Array
(
[0] => 280
)
)
)
now you need to change the two-dimensional array into the following format:
Array
(
[0] => Array
(
[model_name] =>
[model_sub_name] =>
[goods_stock] => 321
[curr_price] => 99
[goods_weight] => 280
)
[1] => Array
(
[model_name] =>
[model_sub_name] =>
[goods_stock] => 321
[curr_price] => 99
[goods_weight] => 280
)
N
[N+1] => Array
(
[model_name] =>
[model_sub_name] => 32A
[goods_stock] => 321
[curr_price] => 99
[goods_weight] => 280
)
[N+2] => Array
(
[model_name] =>
[model_sub_name] => 34A
[goods_stock] => 321
[curr_price] => 99
[goods_weight] => 280
)
)
in the above array, goods_stock, curr_price, and goods_weight are all arrays. If there is only one element in the array of these keys, then on the same premise as model_name, goods_stock, curr_price, and goods_weight all take this value, otherwise, take the values in goods_stock, curr_price, and goods_weight corresponding to the subscript of the elements in model_sub_name. For example, when model_sub_name is "white", the corresponding subscript is 1, and there is only one element for goods_stock, curr_price, and goods_weight in the above array, then take the value of this element, and if it is not an element, take the value of goods_stock [1], curr_price [1], and goods_weight [1]. I do not know whether such a description is understood or not. Turn to the gods for help.