<?php
error_reporting(-1);
function credit($credit_sum, $percent, $commision, $payout, $addition_pay) {
    $total=0;
    $sum=$credit_sum+$addition_pay;
    for ($sum;$sum>0;$sum) {
        if ($sum>=$payout) {
            $sum=$sum*$percent-$payout;
            $total=$total+$commision+$payout;
        }
        else {
            $total=$total+$commision+$sum;
            $sum=0;
        }
    }   
    return $total;
}
$homo_credit_total=credit(4000, 1.04, 500, 5000, 0);
$soft_bank_total=credit(4000, 1.03, 1000, 5000, 0);
$strawberry_bank_total=credit(4000, 1.02, 0, 5000, 7777);
 
echo "HomoBank total amount: {$homo_credit_total}\n";
echo "SoftCredit total amount: {$soft_bank_total}\n";
echo "StrawbberyBank total amount: {$strawberry_bank_total}\n";
?>