Annotation of embedaddon/php/ext/standard/tests/array/array_sum_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_sum() function : usage variations - associative array
3: --FILE--
4: <?php
5: /* Prototype : mixed array_sum(array $input)
6: * Description: Returns the sum of the array entries
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Testing array_sum() with associative array as 'input' argument
12: */
13:
14: echo "*** Testing array_sum() : with associative array ***\n";
15:
16: // array with numeric keys
17: $input = array(0 => 1, 1 => 10, 2 => 0, 3 => -2, 4 => 23.56);
18: echo "-- with numeric keys --\n";
19: var_dump( array_sum($input) );
20:
21: // array with string keys
22: $input = array('a' => 20, "b" => 50, 'c' => 0, 'd' => -30, "e" => 100);
23: echo "-- with string keys --\n";
24: var_dump( array_sum($input) );
25: echo "Done"
26: ?>
27: --EXPECTF--
28: *** Testing array_sum() : with associative array ***
29: -- with numeric keys --
30: float(32.56)
31: -- with string keys --
32: int(140)
33: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>