0
我對PHP相當陌生,並試圖對一個類項目進行排序。我已經衝出去了,看不出來,這是剩下的最後一塊。PHP:平均分類按年份分類
我有一個表格 - 基本上提交2個數組我試圖確定基於類別分組的平均分數。 1.($ _post ['category']),($ _post ['score']) - 類別是基於文本的數組,分數顯然是基於數字的。
我該如何去尋找每個類別的平均分數?我試過各種選項來映射兩個數組,然後嘗試平均分數。我可以非常輕鬆地獲得總平均分,但是找到一種方法可以逐個完成每個分類,這讓我倍感失望。
我需要將權重應用於每個類別分數,但是一旦您獲得上述排序,這似乎很容易。
感謝, 史蒂夫
$ _ POST例如:
Array (
[0] => Assignment
[1] => Assignment
[2] => Assignment
[3] => Assignment
[4] => Assignment
[5] => Assignment
[6] => Exam
[7] => Assignment
[8] => Assignment
[9] => Assignment
[10] => Exam
[11] => Exam
[12] => Final Project
)
Array (
[0] => 100
[1] => 100
[2] => 100
[3] => 98
[4] => 90
[5] => 92
[6] => 100
[7] => 100
[8] => 100
[9] => 100
[10] => 100
[11] => 92
[12] => 100
)
舉一個你$ _POST數組的樣子的例子。 'print_r'可以。 – pilsetnieks 2013-04-28 19:15:40
Array [(0] => Assignment [1] => Assignment [2] => Assignment [3] => Assignment [4] => Assignment [5] => Assignment [6] => Exam [7] =>分配[8] =>分配[9] =>分配[10] =>考試[11] =>考試[12] =>最終項目) 數組([0] => 100 [1] => 100 [2] => 100 [3] => 98 [4] => 90 [5] => 92 [6] => 100 [7] => 100 [8] => 100 [9] => 100 [10 ] => 100 [11] => 92 [12] => 100) – 2013-04-28 19:18:28
您好pilsetnieks - 上面是兩個陣列的輸出 – 2013-04-28 19:21:33