PHP: Pulling lowest values in multiple arrays -
i have 1 element of project holding me , try might have not been able work. can please assist me - sure confused , there easy answer. have 3 multi-dimensional arrays (3 different pricing data different companies), each holding sort of data:
[0] => array ( [itemcode] => 27663 [buy] => 50000 [perquantity] => 5 ) [1] => array ( [itemcode] => 38663 [buy] => 41000 [perquantity] => 4 ) the same itemcodes appear in data 3 companies. create html table has following columns data:
itemcode | supplier1 | supplier2 | supplier3 | difference (2nd lowest minus lowest) 38663 | 12500 | 12425 | 16440 | 75 my question: there shortcut doing this, creating array temp store data? or there concept feel required complete easily?
any appreciated.
i don't know numbers in html table come from, think creating temporary array way go.
$items=array(); foreach ($supplier1 $data) { $items[$data['itemcode']]['supplier1buy'] = $data['buy']; $items[$data['itemcode']]['supplier1perq'] = $data['perquantity']; } foreach ($supplier2 $data) { $items[$data['itemcode']]['supplier2buy'] = $data['buy']; $items[$data['itemcode']]['supplier2perq'] = $data['perquantity']; } // etc. to make prettier code, think i'd need know more how data works. example, don't know if need 'perquantity'. number in html table function of buy , perquantity?
once you've got large $items array, can walk through create rows of html table.
Comments
Post a Comment