Suppose I have this array
[0] => Array
(
[revision_no] => 0
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000001
[gross] => 34650000
[vat] => 3465000
)
[1] => Array
(
[revision_no] => 1
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000001
[gross] => 44650000
[vat] => 4465000
)
[2] => Array
(
[revision_no] => 2
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000001
[gross] => 34650000
[vat] => 3465000
)
[3] => Array
(
[revision_no] => 0
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000002
[gross] => 34650000
[vat] => 3465000
)
[4] => Array
(
[revision_no] => 1
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000002
[gross] => 34650000
[vat] => 3465000
)
[5] => Array
(
[revision_no] => 0
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000003
[gross] => 34650000
[vat] => 3465000
)
[6] => Array
(
[revision_no] => 0
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 2132134923102931
[document_number] => 010.000-12.00000003
[gross] => 34650000
[vat] => 3465000
)
What should I do in PHP to pick uniques based on revision_no
vendor_no
and document_number
. And then for those having the same vendor_no
and document_number
take only the one having the highest revision_no
.
So the result will be like:
[2] => Array
(
[revision_no] => 2
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000001
[gross] => 34650000
[vat] => 3465000
)
[3] => Array
(
[revision_no] => 1
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000002
[gross] => 34650000
[vat] => 3465000
)
[5] => Array
(
[revision_no] => 0
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 311560353071000
[document_number] => 010.000-12.00000003
[gross] => 34650000
[vat] => 3465000
)
[6] => Array
(
[revision_no] => 0
[invoice_type] => PK
[transaction_id] => 5
[vendor_number] => 2132134923102931
[document_number] => 010.000-12.00000003
[gross] => 34650000
[vat] => 3465000
)