// Created on savesnippets.com · https://savesnippets.com/LLyFJvjG1g4dmD round($final, 2), 'interest' => round($final - $principal, 2), ]; } print_r(compoundInterest(10_000, 0.07, 10)); // [ final => 20096.61, interest => 10096.61 ] ← $10k at 7% APR for 10 years, monthly