Skip to content

Instantly share code, notes, and snippets.

@vekexasia
Forked from anonymous/test1.php
Last active December 20, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vekexasia/6154950 to your computer and use it in GitHub Desktop.
Save vekexasia/6154950 to your computer and use it in GitHub Desktop.
<?php
$arr = array(1,2,3,4,5,6,7,8,9,10);
$arrLess = array();
$arrGret = array();
$total = 0;
$nuEle = count($arr);
foreach ($arr as $arr_ele){
$total += $arr_ele;
}
$avg = $total/$nuEle;
foreach ($arr as $arr_ele) {
if ($arr_ele > $avg) {
array_push($arrGret, $arr_ele);
} elseif ($arr_ele < $avg) {
array_push($arrLess, $arr_ele);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment