Combine array values with specific key has same value

I have the following array:

[
    {
       amendment: 1,
       lcnumber: "A1114564564CT",
       31D: "New Note"
    },
   {
      27: "0/0 (Number)(Total)",
      amendment: 1,
      lcnumber: "A1114564564CT",
   },
   {
      amendment: 2,
      lcnumber: "A1114564564CT",
      31D: "IN SINGAPORE (120 Days from L/C issue date)",
      32B: "USD"
   },
   {
     27: "2/2 (Number)(Total)",
     amendment: 2,
     lcnumber: "A1114564564CT",
     39B: "Exceeding"
   }
  ]

What I’m trying to do, is to combine the values into one index with the same amendment count

This is my expected output

 [
    {
       amendment: 1,
       lcnumber: "A1114564564CT",
       31D: "New Note",
       27: "0/0 (Number)(Total)",
    },
   {
      amendment: 2,
      lcnumber: "A1114564564CT",
      31D: "IN SINGAPORE (120 Days from L/C issue date)",
      32B: "USD",
      27: "2/2 (Number)(Total)",
      39B: "Exceeding"
   },
  ]

I’ve tried writing a foreach loop but this didn’t work

foreach($final_datas as $arrflight) {
    $final_array[] = (object) array(
        'lcnumber' => 'AZ300',
        $arrflight['swift_code'] => $arrflight['note']
    ); 
}