求个数组内部组合方法
PHP code1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | <!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http:
-->
array (1) {
[0]=>
array (11) {
[ "order_sn" ]=>
string(13) "2012031551539"
[ "recede_goods_id" ]=>
string(0) ""
[ "recede_num" ]=>
string(3) "2,1"
[ "add_time" ]=>
string(10) "1331799888"
[ "cause" ]=>
string(0) ""
[ "type" ]=>
string(6) "change"
[ "add_manager" ]=>
string(0) ""
[ "change_goods_id" ]=>
string(4) "29,2"
[ "change_goods_size" ]=>
array (2) {
[0]=>
string(1) "2"
[1]=>
string(1) "1"
}
[ "change_goods" ]=>
array (2) {
[0]=>
array (3) {
[ "goods_name" ]=>
string(62) "诗瑞 SWANRING 半透条纹女士平脚裤 橘色半透条纹"
[ "goods_id" ]=>
string(1) "2"
[ "goods_sn" ]=>
string(10) "S12N605112"
}
[1]=>
array (3) {
[ "goods_name" ]=>
string(53) "诗瑞 SWANRING 甜美女士蕾丝三角裤 粉红色"
[ "goods_id" ]=>
string(2) "29"
[ "goods_sn" ]=>
string(10) "S12N603171"
}
}
[ "change_goods_size_name" ]=>
array (2) {
[0]=>
string(1) "M"
[1]=>
string(1) "S"
}
}
}
|
Copy after login
如何将上面的数组改变成
PHP code1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http:
-->
array (1) {
[0]=>
array (11) {
[ "order_sn" ]=>
string(13) "2012031551539"
[ "recede_goods_id" ]=>
string(0) ""
[ "recede_num" ]=>
string(3) "2,1"
[ "add_time" ]=>
string(10) "1331799888"
[ "cause" ]=>
string(0) ""
[ "type" ]=>
string(6) "change"
[ "add_manager" ]=>
string(0) ""
[ "change_goods_id" ]=>
string(4) "29,2"
[ "change_goods_size" ]=>
array (2) {
[0]=>
string(1) "2"
[1]=>
string(1) "1"
}
[ "change_goods" ]=>
array (2) {
[0]=>
array (3) {
[ "goods_name" ]=>
string(62) "诗瑞 SWANRING 半透条纹女士平脚裤 橘色半透条纹"
[ "goods_id" ]=>
string(1) "2"
[ "goods_sn" ]=>
string(10) "S12N605112"
[ "goods_size" ]=>
string(1) "M"
}
[1]=>
array (3) {
[ "goods_name" ]=>
string(53) "诗瑞 SWANRING 甜美女士蕾丝三角裤 粉红色"
[ "goods_id" ]=>
string(2) "29"
[ "goods_sn" ]=>
string(10) "S12N603171"
[ "goods_size" ]=>
string(1) "S"
}
}
}
}
|
Copy after login
就是如何合并change_goods和change_goods_size_name 用change_goods_size_name第一个值给change_goods第一个,并给change_goods创造新的一列goods_size.第二个做第二个。依次类推
------解决方案--------------------
最好是贴出示例数组,不要贴出var_dump的东西,看起来乱。