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. For example:

<?php

$numbers = [1, 2, 3, 4, 5];
$average = array_sum($numbers) / count($numbers);
echo $average;

Watch a course Learn object oriented PHP

This will output "3", which is the average of the numbers 1, 2, 3, 4, and 5.