I have a array and i need to get the average of all the EVEN numbers in the array i already have tried this but it still doesn't work.
$aReeks = array(23,245,1,2,12,-10,46,6,66,9999,-55,348,56,6,66,983);
for ($q = 0; $q < count($aReeks); $q++)
{
{
if ($aReeks[$q] % 2 == 0)
$totaaleven = array_sum($aReeks[$q]) / count($aReeks[$q]);
}
}
echo $totaaleven
;afterecho $totaleven$totaaleven = array_sum($even = array_filter($aReeks,function($v) {return $v%2==0;}))/count($even);No (explicit) looping required...