CKTIS / PHP
array_product()
Multiply the elements to obtain one numeric product, for example a combined scaling factor.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
array_product(array $array): int|floatMultiply the elements to obtain one numeric product, for example a combined scaling factor. The empty product is one. A zero factor produces zero if all preceding products remain finite. Floating-point overflow can instead produce infinity, and infinity times zero gives NAN. Very large integer products may become floating-point numbers and lose exactness. Since PHP 8.3 an element that cannot be converted to int or float raises E_WARNING.
Signature
array_product(array $array): int|float
Example output
[30,1,0,true]
Examples
<?php
echo json_encode([array_product([2,3,5]), array_product([]), array_product([3,0,7]), is_nan(array_product([1e308,1e308,0]))]);
Result
[30,1,0,true]