mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
RFC: https://wiki.php.net/rfc/saner-array-sum-product Moreover, the internal fast_add_function() function was removed.
18 lines
323 B
PHP
18 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)
|