PHP array_product() Function
PHP array_product() Function
The array_product() function in PHP calculates the product of values in an array.
Syntax
array_product ( array $array )
Parameter
array(required)- This parameter represents the input array.
Return
This function returns the product of the array elements as an integer or float. It returns 0 if the array is empty.
Example 1
Output
Input Array: array ( 0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => 6, ) The product of the array is 720
Example 2
Output
Input Array: array ( 0 => 5.6, 1 => 3.42, 2 => 3.3, 3 => 4.44, 4 => 2.35, 5 => 6.0987, ) The product of the array is 4021.7602366972797
Example 3
Output
Input Array: array ( 0 => 'Reema', 1 => 'Sapna', 2 => 'Richa', 3 => 'Twinkle', 4 => 'Samiksha', ) The product of the array is 0
Example 4
Output
Input Array: array ( ) The product of empty array is 1