mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

RFC: https://wiki.php.net/rfc/saner-array-sum-product Moreover, the internal fast_add_function() function was removed.
17 lines
323 B
PHP
17 lines
323 B
PHP
--TEST--
|
|
Test array_sum() function with empty array
|
|
--FILE--
|
|
<?php
|
|
$input = [];
|
|
|
|
echo "array_sum() version:\n";
|
|
var_dump(array_sum($input));
|
|
|
|
echo "array_reduce() version:\n";
|
|
var_dump(array_reduce($input, fn($carry, $value) => $carry + $value, 0));
|
|
?>
|
|
--EXPECT--
|
|
array_sum() version:
|
|
int(0)
|
|
array_reduce() version:
|
|
int(0)
|