问题
数组1如何 可以组合成数组2的形式?
数组1
$a = [
[
'tagId' => '43',
'streetName' => '锦春路',
'placecode' => '010170'
],
[
'tagId' => '44',
'streetName' => '滨湖路',
'placecode' => '010203'
],
[
'tagId' => '44',
'streetName' => '滨湖路',
'placecode' => '010204'
]
];
打印出结果
array (size=3)
0 =>
array (size=3)
'tagId' => string '43' (length=2)
'streetName' => string '锦春路' (length=9)
'placecode' => string '010170' (length=6)
1 =>
array (size=3)
'tagId' => string '44' (length=2)
'streetName' => string '滨湖路' (length=9)
'placecode' => string '010203' (length=6)
2 =>
array (size=3)
'tagId' => string '44' (length=2)
'streetName' => string '滨湖路' (length=9)
'placecode' => string '010204' (length=6)
数组2
$b = [
[
'tagId' => '43',
'streetName' => '锦春路',
'placeCodes' => ['010170']
],
[
'tagId' => '44',
'streetName' => '滨湖路',
'placeCodes' => ['010203','010204']
]
];
打印出结果
array (size=2)
0 =>
array (size=3)
'tagId' => int 43
'streetName' => string '锦春路' (length=9)
'placeCodes' =>
array (size=1)
0 => string '010170' (length=6)
1 =>
array (size=3)
'tagId' => int 44
'streetName' => string '滨湖路' (length=9)
'placeCodes' =>
array (size=2)
0 => string '010203' (length=6)
1 => string '010204' (length=6)
2 回答
- 2 回答
- 0 关注
- 361 浏览
添加回答
举报
0/150
提交
取消