I am looking for a little assistance. Please have a look at the array below. In the array that I have, the same data has been attached to 3 items and a separate item has its own unique data.
Array
(
[0] => Array
(
[item] => 116
[stockcode] => UPGRADE
[qty] => 1
[nett] => 35.3
[vat] => 20
[gross] => 42.36
)
[1] => Array
(
[item] => 117
[stockcode] => UPGRADE
[qty] => 1
[nett] => 35.3
[vat] => 20
[gross] => 42.36
)
[6] => Array
(
[item] => 118
[stockcode] => UPGRADE
[qty] => 1
[nett] => 35.3
[vat] => 20
[gross] => 42.36
)
)
Array
(
[0] => Array
(
[item] => 086
[stockcode] => INS VISIT
[qty] => 1
[nett] => 60
[vat] => 0
[gross] => 60
)
)
In my code, I have the following to try and display the data:
foreach ($section['lines'] as $l) {
//if (count($plots) > 1) :
//echo count($l);
if ($l['is_stockcode']) {
$l['stockcode'] = '<a href="javascript:void(0);" class="stockcode-link" data-id="' . $l['stockcode'] . '" >' . $l['stockcode'] . '</a> ';
}
?>
<tr>
<td class="text-right"><?php echo $l['qty']; ?></td>
<td><?php echo $l['stockcode']; ?></td>
<td class="text-right"><?php echo number_format($l['nett'], 2); ?></td>
<td class="text-right"><?php echo $l['vat']; ?>%</td>
<td class="text-right"><?php echo number_format($l['gross'], 2); ?></td>
</tr>
<?php
$total_nett += $l['nett'];
$total_gross += $l['gross'];
};
What I am trying to achieve is this, seeing as the data from the first array is identical, I only want it to be displayed once. I have done a php join to show the item ids in the format of "116, 117, 118". But rather than having the data repeated 3 times, I would like to have it shown once. Is that possible? I have tried using array_unique, but its stripping out a lot of the data itself. So any help would be appreciated.
Thanks