I have this script…
//initial value
$fund = 10;
$rebate = 0.01; // constant 1 percent
$maturity = 30; //days
echo '<ul>';
echo '<li>Day1 fund: $' . $fund . '</li>';
//day1 value
$fund = incfund($fund); //should return $10.10
echo '<li>Day2 fund: $' . $fund . '</li>';
//day2 value
$fund = incfund($fund); //should return $10.20
echo '<li>Day3 fund: $' . $fund . '</li>';
//day3 value
$fund = incfund($fund); //should return $10.30
echo '<li>Day4 fund: $' . $fund . '</li>';
echo '</ul>';
//continue increasing the fund value daily until day 30...
//function to increase $fund
function incfund($x){
for($i = 0; $i<=$maturity; $i++){
$newfund = $x + $rebate;
$fund = $newfund;
return $fund;
}
}
currently if I run the script, it will output:
Day1 fund: $10
Day2 fund: $10
Day3 fund: $10
Day4 fund: $10
when I really want to output is:
Day1 fund: $10.10
Day2 fund: $10.20
Day3 fund: $10.30
Day4 fund: $10.40
...
...
Day30 fund: $13.00
basically, what I want to do is compute the 1% rebate and compound it to the original fund and then continue compounding until the maturity date.
what could be the problem why I cannot do what I want?
Look at your code
What it really do
What you should change
or
And change view layer for
But as you described your functionality all your code should look like
How to check that day you can find. It simply using http://php.net/mktime and http://php.net/date