Latest web development tutorials

PHP array_product () function

PHP Array Reference Complete PHP Array Reference

Examples

Computes and returns the product of the array:

<?php
$a=array(5,5);
echo(array_product($a));
?>

Running instance »

Definition and Usage

array_product () function calculates and returns the product array.


grammar

array_product( array )

参数 描述
array 必需。规定数组。

technical details

return value: It returns an integer or floating-point product.
PHP version: 5.1.0+
Update log: Since PHP 5.3.6 onwards, the product is an empty array. Prior to PHP 5.3.6, the product of an empty array is zero.


More examples

Example 1

Computes and returns the product of the array:

<?php
$a=array(5,5,2,10);
echo(array_product($a));
?>

Running instance »


PHP Array Reference Complete PHP Array Reference