我目前有一個報告類,它從我的數據庫中提取大量數據並將其格式化爲要返回的4維數組。這工作正常,但我擔心這不是最好的方式。我應該使用JSON,XML,接口等...PHP多維關聯數組替代
基本上什麼是最好的方式來返回這些數據?
下面是我如何使用多維關聯數組返回數據爲例:
$results[$teacherID][$studentID][$subject][$testID]
和結構的樣品圖:
Array
(
[17520] => Array
(
[01356] => Array
(
["Math"] => Array
(
[0130] => 75.2
[0215] => 76.8
)
["Science"] => Array
(
[0130] => 85.2
[0215] => 72.2
[0308] => 96.3
[0320] => 68.4
)
)
[01468] => Array
(
["Math"] => Array
(
[0130] => 23.2
[0215] => 54.8
)
["Science"] => Array
(
[0130] => 72.6
[0215] => 79.1
[0308] => 68.7
[0320] => 72.2
)
)
)
[17522] => Array
(
ect...