<?php

error_reporting(-1);

function countPercent($amountDebt,$percent,$commission,$bankName) {
  $realPrice=0;
  for ($i=1;0<$amountDebt;$i++) {
    $amountDebt=$amountDebt*$percent+$commission;
    if ($amountDebt >= 5000) {
    $amountDebt -= 5000;
    $realPrice += 5000;
    }
    else {
      $realPrice += $amountDebt;
      $amountDebt=0;
    }
  }
  echo "Отчет по {$bankName}\nНастоящая цена {$realPrice}\nМесяцев до полной выплаты {$i}\n---------\n";
}

$homo=countPercent(40000,1.04,500,"Homocredit");
$soft=countPercent(40000,1.03,1000,"Softbank");
$bank=countPercent(47777,1.02,0,"StrawberryBank");

Echo $homo . $soft . $bank;
?>