Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $arr = array(
- 1000000001,
- 1000000002,
- 1000000003,
- 1000000004,
- 1000000005
- );
- $total = 0;
- array_walk($arr, 'totalize');
- echo '*' . $total;
- function totalize( $arr_item ) {
- global $total;
- $total += $arr_item;
- }
- $arr = array(
- 1000000001,
- 1000000002,
- 1000000003,
- 1000000004,
- 1000000005
- );
- $total = 0;
- array_walk($arr, 'totalize', $total);
- echo '*' . $total;
- function totalize( $arr_item, $key, &$total ) {
- $total += $arr_item;
- echo $arr_item . '.' . $key . '.' . $total . '<br />';
- }
- 1000000001.0.1000000001
- 1000000002.1.2000000003
- 1000000003.2.3000000006
- 1000000004.3.4000000010
- 1000000005.4.5000000015
- *0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement