I have been going round in circles with this and I'm hoping someone can help.
I have a .csv file containing data, example:
Weight, 10, 20, 30, 40
product1, 1, 2, 3, 4
product2, 2, 4, 6, 8
product3, 3, 6, 9, 12
What I need to do, using PHP, is select the value from the matrix where the row is "product2" and the number in that row corresponds with the nearest rounded match to a Weight of 27. The result should therefore be 6.
I've tried adding the csv rows to an array using fgetcsv and looping through to get the line where the first array item = product2, but I can't cross reference it with the Weight values from line 1.
I appreciate this csv is effectively upside down but this is the easiest way to manage it.
I can post some code I've tried so if it helps but, to be honest, it's all a bit of a mess so I was hoping someone could point me in the right direction with some working code.
Any help is appreciated! Thanks.