function rente($geldSom) { static $aantalJaar = 10; static $counter = 0; static $renteVoet = 1.08; static $totaal = 0; if ($counter != $aantalJaar) { $totaal = $geldSom * $renteVoet; ++$counter; echo "Mijn geld heeft na " . $counter . " jaar €" . $totaal . " opgebracht" . "<br>"; rente($totaal); } else { echo "De " . $aantalJaar . " jaar is voorbij"; } }
function rente($geldSom) { global $aantalJaar; global $counter; global $renteVoet; $totaal = 0; global $volledigeInfo; if ($counter != $aantalJaar) { $totaal = $geldSom * $renteVoet; ++$counter; echo "Mijn geld heeft na " . $counter . " jaar €" . $totaal . " opgebracht" . "<br>"; $volledigeInfo["jaar" . $counter] = $totaal; rente($totaal); } else { echo "De " . $aantalJaar . " jaar sparen is voorbij"; } }