$suma = array("anticipo" => 0, "co_total" => 0, "co_aprobado" => 0, "remanente" => 0); foreach ($resultado as $fila) { $aux .= "<tr>"; foreach ($fila as $nombre => $dato) { $xls .= "{$dato}\t"; $aux .= "<td style=\"font-size: 9px;\" align='right'>{$dato}</td>"; foreach ($suma as $valores => $valor) { if ($valores == $nombre) { $suma[$valores] = number_format($valor + $dato, 2, ".", ""); } } } $aux .= "</tr>"; } $aux .= "<tr>"; $aux .= "<td colspan='4'> </td>"; $aux .= "<td style=\"font-size: 9px;\" align='right'><strong>{$suma['anticipo']}</strong></td>"; $aux .= "<td style=\"font-size: 9px;\" align='right'> </td>"; $aux .= "<td style=\"font-size: 9px;\" align='right'><strong>{$suma['co_total']}</strong></td>"; $aux .= "<td style=\"font-size: 9px;\" align='right'><strong>{$suma['co_aprobado']}</strong></td>"; $aux .= "<td style=\"font-size: 9px;\" align='right'><strong>{$suma['remanente']}</strong></td>"; $aux .= "</tr>"; $aux .= "</table>"; $aux .= "</body>"; $aux .= "</html>"; echo $aux; } $I->footer(); ?> </html>