ok this might get confusing so ill keep it simple i have for my online store a simple script which pulls a data feed in csv from my suppliers website to keep my stock levels up to date. The csv file is saved on my server and is in the following format coloumn A is the product id coloumn B is the quantity in stock relating to the product id in column A. Now the confusing bit Within my store i have some products with individual ids that are a combination of other products. eg STACK1PRODUCTID = PRODUCTID 1 + PRODUCTID2 + PRODUCTID3 What i need is a php script that takes the product ids that i define and then takes the stock level from each of the product ids and checks for the lowest stock level from the products that make up the stack. eg product id 1 qty = 100 product id 2 qty = 5 product id 3 qty = 0 i need the script to scrape the quantitys from the original csv file on my server and then create a new csv file with the product id for the stack in coloumn A and the LOWEST from the stack quantity in column B then save the new csv file. the result would be Coloumn A in CSV = stackproductid Column B = Lowest stock level from the product ids defined in the php file does this make any sense to anyone? If your into sports nutrition and supplementation you will get an idea of what a stack is.