0

I have been stuck on this situation for a couple of weeks now and finally took up the courage to post it online..

I have the following array:

[84] => Array (
[TaxBaseAmount] => 7475.41
[DocDate] => 0000-00-00
[DocNo] => 1
[Tx] => D4
[ID] => 84
[BusinessPartnerName] =>Name
)
[) Array ( 63] => Array (
[TaxBaseAmount] => -1585.74
[DocDate] => 0000-00-00
[DocNo] => 1
[Tx] => O1
[ID] => 63
[BusinessPartnerName] => Name
)
[18] => Array (
[TaxBaseAmount] => -340.00
[DocDate] => 0000-00-00
[DocNo] => 2
[Tx] => D4
[ID] => 18
[BusinessPartnerName] => Name2
)
[) Array ( 80] => Array (
[TaxBaseAmount] => 3686.49
[DocDate] => 0000-00-00
[DocNo] => 3
[Tx] => 15
[ID] => 80
[BusinessPartnerName] => Name2
)

What i want to achive is sum up all the values of TaxBaseAmount where the BusinessPartnerName is the same..AND the Document contains atleast ONE Tx="D4" So from the example above the result should be..

Array (
[TaxBaseAmount] => 5889.67
[DocDate] => 0000-00-00
[DocNo] => 1
[Tx] => D4
[BusinessPartnerName] =>Name
)

So i summed up the first two because they both had the same BusinessPartnerName (Name) and although only one of them had the Tx="D4" the other one shared the same DocNo(1)..

 Array (
[TaxBaseAmount] => -340.00
[DocDate] => 0000-00-00
[DocNo] => 2
[Tx] => D4
[BusinessPartnerName] =>Name2
)

With the last two although they share the same BusinessPartnerName(Name2) they do not share the same DocNo . . One is DocNo=2 and the other one DocNo=3..

Hopefuly someone can help me since i´m kinda of a novice when it comes to arrays..

The language i´m working in is PHP.

/Cheers

Tim
  • 41,901
  • 18
  • 127
  • 145
Mwahi
  • 1
  • 1

0 Answers0