I must to calculate the value of an array taken from a query only if had more than one element, else I must to return the value of the element, I'm using this code:

```
function calculate_average($arr) {
  if (count($arr) === 1) {
    $average = $arr;
  } else {
    sort($arr);
    $count = count($arr); //count items in array
    $sum = array_sum($arr); //sum of numbers in array
    $median = $sum / $count; //divide sum by count
    $average = ceil($median); //convert number in excess value
  }
   return $average;
}

```

And work when there is two or more value, but return NULL when there is only one value, why?

Thanks to all who want to partecipate.