-1
我如何通過houseid對這個數組進行分組?如何在PHP中對數組進行分組?
Array
(
[0] => stdClass Object
(
[id] => 1111
[houseid] => 58
[price] => 2995
)
[1] => stdClass Object
(
[id] => 1112
[houseid] => 58
[price] => 4050
)
[2] => stdClass Object
(
[id] => 1114
[houseid] => 60
[price] => 1695
)
[3] => stdClass Object
(
[id] => 1115
[houseid] => 60
[price] => 2250
)
[4] => stdClass Object
(
[id] => 1116
[houseid] => 60
[price] => 2295
)
)
我需要計算總價格爲houseid和做一些數學/條件,如果組數組...
我可以格式化這個數組類似
它會很容易Array
(
[58] => stdClass Object(
[0] => stdClass Object
(
[id] => 1111
[price] => 2995
)
[1] => stdClass Object
(
[id] => 1112
[houseid] => 58
[price] => 4050
)
)
[60] => stdClass Object(
[0] => stdClass Object(
[id] => 1114
[price] => 1695
)
[1] => stdClass Object
(
[id] => 1115
[price] => 2250
)
[2] => stdClass Object
(
[id] => 1116
[price] => 2295
)
)
或者任何人都可以建議我,如何循環原始數組來計算一個房子的總價格?
向我們展示[你已經試過(http://www.whathaveyoutried.com)。這方面有很多類似的問答。 – Kermit
我需要得到一些日期之間的houseids,並從sql語句中得到這個數組...我需要將它重新格式化爲需要 –
,它們有很多數組函數,他們至少應該在提問之前檢查它們顯示沒有努力 –