code: public function quartile(array $collections, $number)
      {
          sort($collections);
          $cnt = count($collections);
  
          if ($cnt === 0) {
              return 0;
          } elseif ($cnt === 1) {
              return $collections[0];
          }
  
          switch ($number) {
              case 2:
                  $part = (int) $cnt / 2;
                  if ($cnt % 2 === 0) {
                      return ($collections[$part - 1] + $collections[$part]) / 2;
                  } else {
                      return $collections[round($cnt / 2) - 1];
                  }
              default:
                  if ($cnt % 2 === 0) {
                      return $collections[(round($number * $cnt / 4)) - 1];
                  } else {
                      return $collections[(round($number * ($cnt + 1) / 4)) - 1];
                  }
                  break;
          }
      }
docs: Count quartile from collections by number quartile
  http://www.stat.gov.pl/gus/definicje_PLK_HTML.htm?id=POJ-7498.htm
  
  @param array $collections
  @param int $number
  @return float