I got the following array.
[0]=>
array(7) {
[0]=>31
[1]=>14
[2]=>on
[3]=>receiver
[4]=>pollin
[5]=>0000-e8-de-27-176d10
[6]=>1
}
[1]=>
array(7) {
[0]=>31
[1]=>14
[2]=>on
[3]=>receiver
[4]=>pollin
[5]=>0000-e8-de-27-176d10
[6]=>5
}
[2]=>
array(7) {
[0]=>0
[1]=>17
[2]=>"on"
[3]=>"receiver"
[4]=>"elro_400"
[5]=>"0000-e8-de-27-176d10"
[6]=>1
}
I'm trying to sum the value of [6] together, but only if the value of key 0-5 are the same. so the expected result would be this:
[0]=>
array(7) {
[0]=>31
[1]=>14
[2]=>on
[3]=>receiver
[4]=>pollin
[5]=>0000-e8-de-27-176d10
[6]=>6
}
[1]=>
array(7) {
[0]=>0
[1]=>17
[2]=>"on"
[3]=>"receiver"
[4]=>"elro_400"
[5]=>"0000-e8-de-27-176d10"
[6]=>1
}
I tried it myself with if(array_key_exists($vals[0]&&$vals[1]&&$vals[2]&&$vals[3]&&$vals[4]&&$vals[5],$res)) however this is not working like I thought it would work.
EDIT:
What I'm trying to do is remove duplicates if [0] - [5] are the same. But when it removes a duplicate it should sum [6] together.
Simple Example:
[0]=>
array(3) {
[0]=>31
[1]=>14
[2]=>1
}
[1]=>
array(3) {
[0]=>31
[1]=>14
[2]=>4
}
[2]=>
array(3) {
[0]=>3
[1]=>18
[2]=>1
}
If [0] and [1] are the same, then it well remove the duplicates but add together [2]
So that would result in:
[0]=>
array(3) {
[0]=>31
[1]=>14
[2]=>5
}
[1]=>
array(3) {
[0]=>3
[1]=>18
[2]=>1
}
foreach()loop6is calculated. Would not you want to store it in a separate variable?