Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. $arr = array(
  2. 1000000001,
  3. 1000000002,
  4. 1000000003,
  5. 1000000004,
  6. 1000000005
  7. );
  8.  
  9. $total = 0;
  10. array_walk($arr, 'totalize');
  11. echo '*' . $total;
  12.  
  13. function totalize( $arr_item ) {
  14. global $total;
  15. $total += $arr_item;
  16. }
  17.  
  18. $arr = array(
  19. 1000000001,
  20. 1000000002,
  21. 1000000003,
  22. 1000000004,
  23. 1000000005
  24. );
  25.  
  26. $total = 0;
  27. array_walk($arr, 'totalize', $total);
  28. echo '*' . $total;
  29.  
  30. function totalize( $arr_item, $key, &$total ) {
  31. $total += $arr_item;
  32. echo $arr_item . '.' . $key . '.' . $total . '<br />';
  33. }
  34.  
  35. 1000000001.0.1000000001
  36. 1000000002.1.2000000003
  37. 1000000003.2.3000000006
  38. 1000000004.3.4000000010
  39. 1000000005.4.5000000015
  40. *0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement