Find common values in multiple arrays with PHP
Pretty much does what I need, but in PHP, I need VB.
My situation is I am trying to create an intelligent stock pick system based on multiple stock locations.
At the point of invoicing, we loop through the items invoiced and check the stock database for available stock.
If all items on the invoice are available to pick from stock location 1, then all should be picked from stock location 1... etc.
If all most items are available from stock location 1 except one or two, then pick all stock from stock location 1 except for the exceptions which should be picked from the location with the highest available stock.
Finding highest available stock is simple, but I can't work out how to analyse the stock availability from multiple locations and finding the common stock locations.
I can create a set of arrays like this
Item ID | Available Stock Locations
1 | 2, 3, 5
2 | 1, 2, 6
3 | 2, 3, 4
4 | 1, 2 ,3
How to I compare those location lists to find that 2
is common to all four?
Secondly, if one Item did not have a common stock location, how would I identify that item so I can go back and find the highest available stock level for it?