Created
September 3, 2013 03:07
-
-
Save phpfiddle/6419312 to your computer and use it in GitHub Desktop.
Calculate costumize array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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