<?php
const INTEREST_RATE_MIN = 10;
const INTEREST_RATE_MAX = 15;
const YEARS = 10;
$deposit = 100000;
$profit = [];
for($i = INTEREST_RATE_MIN; $i <= INTEREST_RATE_MAX; $i++){
for($j = 1; $j <= YEARS; $j++){
$balance = $j > 1 ? $profit[$i][$j - 1] : $deposit;
$profit[$i][$j] = $balance + getPercentOf($deposit, $i);
}
}
echo "<pre>";
print_r($profit);
echo "</pre>";
function getPercentOf($number, $percent){
return ($number / 100) * $percent;
}
На выходе
Array
(
[10] => Array
(
[1] => 110000
[2] => 120000
[3] => 130000
[4] => 140000
[5] => 150000
[6] => 160000
[7] => 170000
[8] => 180000
[9] => 190000
[10] => 200000
)
[11] => Array
(
[1] => 111000
[2] => 122000
[3] => 133000
[4] => 144000
[5] => 155000
[6] => 166000
[7] => 177000
[8] => 188000
[9] => 199000
[10] => 210000
)
[12] => Array
(
[1] => 112000
[2] => 124000
[3] => 136000
[4] => 148000
[5] => 160000
[6] => 172000
[7] => 184000
[8] => 196000
[9] => 208000
[10] => 220000
)
Как распечатать полученную информацию в 1 таблице?