note 127879 added to function.array-product
| From: | biziclop at main dot php dot net | Date: | Sun, 30 Oct 2022 23:21:38 +0000 |
| Subject: | note 127879 added to function.array-product | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219833@lists.php.net to get a copy of this message | ||
You can use array_product() to calculate the geometric mean of an array of numbers:
<?php
$a = [ 1, 10, 100 ];
$geom_avg = pow( array_product( $a ), 1 / count( $a ));
// = 9.999999999999998 â 10
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.159.161 (proxied: 188.143.0.221)
----
Manual Page -- https://php.net/manual/en/function.array-product.php
Edit -- https://main.php.net/note/edit/127879
Del: integrated -- https://main.php.net/note/delete/127879/integrated
Del: useless -- https://main.php.net/note/delete/127879/useless
Del: bad code -- https://main.php.net/note/delete/127879/bad+code
Del: spam -- https://main.php.net/note/delete/127879/spam
Del: non-english -- https://main.php.net/note/delete/127879/non-english
Del: in docs -- https://main.php.net/note/delete/127879/in+docs
Del: other reasons-- https://main.php.net/note/delete/127879
Reject -- https://main.php.net/note/reject/127879
Search -- https://main.php.net/manage/user-notes.php