How to find average from array in php?
You can use the array_sum function to get the sum of all the values in an array, and then divide that sum by the number of elements in the array to get the average.
You can use the array_sum function to get the sum of all the values in an array, and then divide that sum by the number of elements in the array to get the average. For example:
Example of finding the average of an array in PHP
php— editable, runs on the server
Info
Watch a video course: Learn object oriented PHP
This will output "3", which is the average of the numbers 1, 2, 3, 4, and 5.