PHP Tutorial - PHP array_product() Function






Definition

The array_product() function calculates the product of an array.

Syntax

PHP array_product() Function has the following syntax.

array_product(array)

Parameter

  • array - Required. Array to calculate

Example

Calculate and return the product of an array:


<?php//w w w  . ja  v a2 s . c  om
    $a=array(5,5);
    print_r($a);
    echo(array_product($a));

    echo "\n";
    $a=array(5,5,2,10);
    print_r($a);
    echo(array_product($a));
?>

The code above generates the following result.