I have this array`
<?php
$arr = [['name'=>'john','age'=>20,'sex'=>'m'],
['name'=>'maria','age'=>12,'sex'=>'f'],
['name'=>'nick','age'=>25,'sex'=>'m'],
['name'=>'jo','age'=>31,'sex'=>'f'],];
foreach ($arr as $persoana) {
foreach ($persoana as $id=>$value) {
if ($id == 'age') {
$sumvarsta = $sumvarsta + $value;
$n++;
}
}
}`?>
i need total average age (total average age seems to be working ok) , average age for women and average age for men. How to calculate ?
thx.