array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.array-product.php', 1 => 'array_product', 2 => 'Calculate the product of values in an array', ), 'up' => array ( 0 => 'ref.array.php', 1 => 'Функції для роботи з масивами', ), 'prev' => array ( 0 => 'function.array-pop.php', 1 => 'array_pop', ), 'next' => array ( 0 => 'function.array-push.php', 1 => 'array_push', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/array/functions/array-product.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
array_product — Calculate the product of values in an array
array_product() returns the product of values in an array.
array
The array.
Returns the product as an integer or float.
Версія | Опис |
---|---|
8.3.0 |
Now emits E_WARNING when array values
cannot be converted to int or float.
Previously arrays and objects where ignored whilst every other value was cast to int.
Moreover, objects that define a numeric cast (e.g. GMP) are now cast instead of ignored.
|
Приклад #1 array_product() examples
<?php
$a = array(2, 4, 6, 8);
echo "product(a) = " . array_product($a) . "\n";
echo "product(array()) = " . array_product(array()) . "\n";
?>
Поданий вище приклад виведе:
product(a) = 384 product(array()) = 1