Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created September 3, 2013 03:07
Show Gist options
  • Save phpfiddle/6419312 to your computer and use it in GitHub Desktop.
Save phpfiddle/6419312 to your computer and use it in GitHub Desktop.
Calculate costumize array
<?php
function calculate($array_1, $array_2){
$x = 0; $total = 0;
foreach($array_1 as $element){
$total += ($element - $array_2[$x]);
$x++;
}
return ($total / count($array_1));
}
echo calculate(array(6, 3, 3, 4), array(8, 7, 6, 5));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment