farshadf
1 week ago
112
4
Laravel

how to get the sum of 2 array with the same id in a collection

Posted 1 week ago by farshadf

i have an array of collections with some same occurrences like below :

array:6 [▼
  0 => Collection {#926 ▶}
  1 => Collection {#926 ▶}
  2 => Collection {#1045 ▶}
  3 => Collection {#1045 ▶}
  4 => Collection {#1156 ▶}
  5 => Collection {#1156 ▶}
]

now what i want to do is to is to get the sum of those who repeated like 926 so i would have 2 prices to sum because 926 occurred 2 times . how can i achieve that thanks !

Please sign in or create an account to participate in this conversation.