12345678910111213141516171819202122
  1. <?php
  2. namespace App\Services;
  3. class Helper
  4. {
  5. public static function addPrevValue(array $h): array
  6. {
  7. $i = [];
  8. for ($j = 0; $j <= count($h) - 1; $j++) {
  9. if ($j === 0) {
  10. array_push($i, $h[$j]);
  11. } else {
  12. array_push($i, $i[$j - 1] + $h[$j]);
  13. }
  14. }
  15. return $i;
  16. }
  17. }