fork download
  1. <?php
  2.  
  3. $suma = array();
  4.  
  5. $tablica = array(
  6. 1,
  7. 2,
  8. 3,
  9. 4,
  10. 5,
  11. 1
  12. ),
  13. 2,
  14. 4,
  15. 0,
  16. 2,
  17. 5,
  18. 9
  19. )
  20. );
  21. foreach($tablica as $tab)
  22. {
  23. for($i=0;$i<=sizeof($tab); $i++)
  24. {
  25. if(isset($suma[$i]))
  26. {
  27. $suma[$i]+=$tab[$i];
  28. }
  29. else
  30. {
  31. $suma[$i]=$tab[$i];
  32. }
  33. }
  34. }
  35.  
  36. var_dump($suma);
Success #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
array(7) {
  [0]=>
  int(3)
  [1]=>
  int(6)
  [2]=>
  int(3)
  [3]=>
  int(6)
  [4]=>
  int(10)
  [5]=>
  int(10)
  [6]=>
  NULL
}
stderr
PHP Notice:  Undefined offset: 6 in /home/fCCdJy/prog.php on line 33
PHP Notice:  Undefined offset: 6 in /home/fCCdJy/prog.php on line 33