code: public static function MEDIAN(...$args)
      {
          $returnValue = Functions::NAN();
  
          $mArgs = [];
          // Loop through arguments
          $aArgs = Functions::flattenArray($args);
          foreach ($aArgs as $arg) {
              // Is it a numeric value?
              if ((is_numeric($arg)) && (!is_string($arg))) {
                  $mArgs[] = $arg;
              }
          }
  
          $mValueCount = count($mArgs);
          if ($mValueCount > 0) {
              sort($mArgs, SORT_NUMERIC);
              $mValueCount = $mValueCount / 2;
              if ($mValueCount == floor($mValueCount)) {
                  $returnValue = ($mArgs[$mValueCount--] + $mArgs[$mValueCount]) / 2;
              } else {
                  $mValueCount = floor($mValueCount);
                  $returnValue = $mArgs[$mValueCount];
              }
          }
  
          return $returnValue;
      }
docs: MEDIAN.
  
  Returns the median of the given numbers. The median is the number in the middle of a set of numbers.
  
  Excel Function:
  MEDIAN(value1[,value2[, ...]])
  
  @category Statistical Functions
  
  @param mixed ...$args Data values
  
  @return float