Azizal Yunan P Azizal Yunan P - 2 months ago 22
MySQL Question

get last data from foreach object data

how to get last data from foreach , i want to save for last data to result ,

image for result :

Result

enter image description here

<?php
$s_kredit = 0;
foreach ($ju as $j ) {
$s_debet += $j->debet - $j->kredit;
$s_kredit += $j->kredit - $j->debet;
<tr>
<td class="center"><?php if(@$set_saldo->debet==0) { echo "-"; } else { echo number_format($s_debet,0,".","."); } ;?></td>
<td class="center"><?php if(@$set_saldo->kredit==0) { echo "-"; } else { echo number_format($s_kredit,0,".","."); } ;?></td>
</tr>

Answer
<?php 
$data=array(1,3,4,5,6,7,7);
$last = $data[count($data) - 1]; 
?>