I'm working on some loan project with php which installments are created by the code below. Note:the first installment should be dated to the next month from $loanyearacc and $loanmonthacc. for example if the loan accepted in 12/01/2018,the first installment is 01/01/2019 the code is:
$loanmonthacc=12;
$loanyearacc=2018;
$loanreqmonth=18;
for($i=$loanmonthacc+1;$i<=$loanmonthacc+$loanreqmonth+1;$i++){
if($i%12==0){
$m=12;
}
else{
$m=$i%12;
}
echo 'i: '.$i.'year: '.$loanyearacc.'month: '.$m.'<br>';
if($i%12==0){
$loanyearacc++;
}
if($i%13==0){
$loanyearacc++;
}
}
Code above works fine just in case that $loanmonthacc is not equal to 12. but if $loanmonthacc equals to 12, JUST the first installment would be next month BUT the year wont increase. can anyone please help me? Sorry for my weak english guys :)