Home >> PHP >> How can find average from an array in PHP

How can find average from an array in PHP

$a=array(110,20,130,100,2);

$avg=0;

for($i=0;$i<count($a)-1;$i++){

   $avg+=$a[$i];

}

$totalavg=$avg/count($a);

echo $totalavg;

Post Your Comment

Next Questions
How can find max element from an array
How can find min element from an array
How to connect mysql database with php
Remember password
How can find reverse string without function
How can find reverse word of string without function
How can print reverse string and show in array without function
How to insert data from mysql database
How to update data from mysql database
How to delete data from mysql database
How to list data from mysql database
error_reporting
error_reporting(E_ALL)
What is object oriented programming (oops)
What is class
What is object
What is static variable
What is static method
What is constructor
Why use constructor
Predefined constructor
Parameterized constructor
What is destructor
What is Polymorphism
What is Polymorphism types

Copyright ©2022 coderraj.com. All Rights Reserved.