array_sum_basic.phpt 991 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Test array_sum() function : basic functionality
  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. echo "*** Testing array_sum() : basic functionality ***\n";
  10. // array with integer values
  11. $input = array(1, 2, 3, 4, 5);
  12. echo "-- array_sum() with integer array entries --\n";
  13. var_dump( array_sum($input) );
  14. // array with float values
  15. $input = array(1.0, 2.2, 3.4, 4.6);
  16. echo "-- array_sum() with float array entries --\n";
  17. var_dump( array_sum($input) );
  18. // array with integer and float values
  19. $input = array(1, 2.3, 4, 0.6, 10);
  20. echo "-- array_sum() with integer/float array entries --\n";
  21. var_dump( array_sum($input) );
  22. echo "Done"
  23. ?>
  24. --EXPECTF--
  25. *** Testing array_sum() : basic functionality ***
  26. -- array_sum() with integer array entries --
  27. int(15)
  28. -- array_sum() with float array entries --
  29. float(11.2)
  30. -- array_sum() with integer/float array entries --
  31. float(17.9)
  32. Done