3v4l.org

run code in 300+ PHP versions simultaneously
<?php class InterestCalculator { private array $dailyInterest = []; private static int $interest = 89; public function calculateDailyInterest(string $start, string $end): array { $this->dailyInterest = array_fill(0, date_diff(date_create($start), date_create($end))->format('%a'), self::$interest); $total = array_sum($this->dailyInterest); array_walk($this->dailyInterest, function (int &$value, int $key): void { $value = ($this->dailyInterest[$key -1] ?? 0) + $value; }); return compact('total') + ['dailyInterest' => $this->dailyInterest]; } } print_r((new InterestCalculator)->calculateDailyInterest('2022-06-06', '2023-06-04'));

Abusive script

This script was stopped while abusing our resources


preferences:
31.44 ms | 410 KiB | 5 Q