为了账号安全,请及时绑定邮箱和手机立即绑定

数组根据值 如何进行合并处理

数组根据值 如何进行合并处理

PHP
开心每一天1111 2019-03-14 22:05:25
问题 数组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
提交
取消
意见反馈 帮助中心 APP下载
官方微信