update : 2015.11.03
php.shukuma.com

검색:
 
 
Calculate the product of values in an array

array_product

(PHP 5 >= 5.1.0, PHP 7)

array_productCalculate the product of values in an array

설명

number array_product ( array $array )

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

인수

array

The array.

반환값

Returns the product as an integer or float.

변경점

버전 설명
5.3.6 The product of an empty array is now 1, when before this function would return 0 for an empty array.

예제

Example #1 array_product() examples

<?php

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

?>

위 예제의 출력:

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