Array $test_count
array ( 0 => array ( 0 => array ( 'it_id' => '212', 'item' => 'Item 1', 'quantity' => '5', ), 1 => array ( 'it_id' => '1206', 'item' => 'Item 2', 'quantity' => '1', ), 2 => array ( 'it_id' => '212', 'item' => 'Item 1', 'quantity' => '1', ), ), )
I need to output key quantity value common value if same array it_id is same, if same item is more than one time in array. Every item have it_id(for id) with value, item(for name) with value, quantity with value, than second item in same way...
Output example for now:
Item id : 212 Key quantity: 2
Item id : 1206 Key quantity: 1
Code for output:
foreach($test_count as $tempo => $lol){
foreach ($lol as $value1) {
$numbers1[$value1[it_id]]++;
}
foreach ($numbers1 as $key1 => $value1) {
if ($value1 > 1){
echo '<font style="color:red;"> Item id : '.$key1.' Key quantity: '.$value1.'</font><br/>';
}else{
echo 'Item id : '.$key1.' Key quantity: '.$value1.'<br/>';
}
}
}
For now i abble to find multiple items in this array using id_it and display how many of them is in array, but totally don't know how to count quantity, how to take more than one key from same array. To get result like this one:
Item id : 212 Key quantity: 2 Item 1 quantity: 7
Item id : 1206 Key quantity: 1 Item 2 quantity: 1
Solved, check answers
small bonus, if you wish to see result not in array but in almost userfrendly way, here is the code for table from result:
code
echo '<table rules="all" border="1">';
foreach($out as $name => $ar) {
foreach($ar as $v1 => $v2) {
echo sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>'."\r\n",
$name, $v1, $v2);
}
}
echo '</table>';