3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getyearly($monthly, $yearly) { if(!empty($monthly) && !empty($yearly)) { $permonth=intdiv((int)$yearly, 12); echo "Single payment will feel like 12-monthly payments of: $permonth (" , $permonth *12 . ")\n"; $monthlytoyear=(int)$monthly*12; echo "Making monthly payments will actually come to: $monthlytoyear\n"; $aftersub = $monthlytoyear-$yearly; echo "That is a difference of: $aftersub\n"; $afterdiv = $aftersub / $yearly; echo "In other words, a savings of: " , $afterdiv , "\n"; $finaly=(int)($afterdiv*100); return "$ ".$yearly."/year ($".round($permonth)."/month; save ~{$finaly}%)"; } else { return '$ '.$yearly.'/yearly'; } } $monthly='60'; $yearly= '480'; echo getyearly($monthly,$yearly);

preferences:
45.62 ms | 405 KiB | 5 Q