<?php

print_r(average([4, 1, 5, 3, 7]));

function average($array){
	$count = 0;
	$sum = 0;
	foreach ($array as $item) {
		// Calculates the number of array members
		$count++;
		
		// Calculates sum of the array
		$sum += $item;
	}
	return $sum/$count;
}

// Using built-in functions
function calculateDetails_builtin($array){
	return array_sum($array)/count($array);
}
by ვაჟა ტყემალაძე
2 years ago
PHP
Problem Solving
php
Note
Problem
PHP Object Oriented Programming (OOP)
0
Pro tip: use ```triple backticks around text``` to write in code fences