code: public static function TRANSPOSE($matrixData)
      {
          $returnMatrix = [];
          if (!is_array($matrixData)) {
              $matrixData = [[$matrixData]];
          }
  
          $column = 0;
          foreach ($matrixData as $matrixRow) {
              $row = 0;
              foreach ($matrixRow as $matrixCell) {
                  $returnMatrix[$row][$column] = $matrixCell;
                  ++$row;
              }
              ++$column;
          }
  
          return $returnMatrix;
      }
docs: TRANSPOSE.
  
  @param array $matrixData A matrix of values
  
  @return array
  
  Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix