Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

array_product()

Example

Compute and return the product of the values in an array.

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

Definition and Usage

The array_product() function computes and returns the product of all the elements in an array.

Syntax

array_product(array)

Parameter Values

 

Parameter

Description

array

Required. Provides an array.

Technical Details

Return Value:

Returns the product as an integer or float.

PHP Version:

5.1.0+

Changelog:

As of PHP 5.3.6, the product of an empty array is 1. Prior to PHP 5.3.6, this function returned 0 for an empty array.

More Examples

Example

Compute and return the product of the elements in an array.

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