How can I aggregate the values from JSON array in PHP [closed]

I’ve a sample JSON array

array:3445 [
   0 => {#605
     +"id": 4074
     +"name": "Suraj J"
     +"type": "ABC"
  }
  1 => {#604
    +"id": 4074
    +"name": "Suraj J"
    +"type": "ABC"

  }
  2 => {#532
    +"id": 4074
    +"name": "Suraj J"
    +"type": "DEF"
  }
  3 => {#533
    +"id": 4075
    +"name": "Aster"
    +"type": "ABC"
  }
]

How can I get an aggregate count based on id and type in the JSON array. To be more clear, the id 4074 has three objects and has 2 different type 2 ABC’s and 1 DEF’s, so my aggregate JSON array would like

array:3445 [
 0 => {#605
   +"id": 4074
   +"name": "Suraj J"
   +"abc_type_count": 2
   +"def_type_count": 1
 }
 1 => {#604
   +"id": 4075
   +"name": "Aster"
   +"type_abc_count": 1
 }

]