Example 1 — Multiply a List of Numbers
Find the product of three small numbers.
<?php
$numbers = [2, 3, 4];
echo array_product($numbers), PHP_EOL; How It Works
- Create an array. It holds 2, 3 and 4.
- Call array_product(). PHP multiplies them one by one.
- Calculate. 2 x 3 is 6, and 6 x 4 is 24.
- Print the result. The output is
24.

