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

问题

数组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)
开心每一天1111
浏览 365回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP