PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

array_product

(PHP 5 >= 5.1.0)

array_productCalculate the product of values in an array

Description

number array_product ( array $array )

array_product() returns the product of values in an array.

Parameters

array

The array.

Return Values

Returns the product as an integer or float.

Changelog

Version Description
5.3.6 The product of an empty array is now 1, when before this function would return 0 for an empty array.

Examples

Example #1 array_product() examples

<?php

$a 
= array(2468);
echo 
"product(a) = " array_product($a) . "\n";
echo 
"product(array()) = " array_product(array()) . "\n";

?>

The above example will output:

product(a) = 384
product(array()) = 1

PHP Manual