如何將這些數組合並在一起?PHP - 按鍵合併2D數組
Array
(
[0] => Array
(
[type] => Person
[relevance] => 0.700000
[count] => 300
[text] => Chris
)
)
Array
(
[0] => Array
(
[type] => Person
[relevance] => 0.900000
[count] => 400
[text] => Chris
)
[1] => Array
(
[type] => Person
[relevance] => 0.500000
[count] => 200
[text] => Tom
)
)
或陣列是這樣的:
Array
(
[0] => Array
(
[type] => Person
[relevance] => 0.700000
[count] => 300
[text] => Chris
)
[1] => Array
(
[type] => Person
[relevance] => 0.900000
[count] => 400
[text] => Chris
)
[2] => Array
(
[type] => Person
[relevance] => 0.500000
[count] => 200
[text] => Tom
)
)
預期的結果是:
Array
(
[0] => Array
(
[type] => Person
[relevance] => 0.800000
[count] => 700
[text] => Chris
)
[1] => Array
(
[type] => Person
[relevance] => 0.500000
[count] => 200
[text] => Tom
)
)
[相關性]值是平均值數
[COUNT]值是增量號碼
這些數組的合併應基於[文本]值。 我該如何用快速的方法來做到這一點?
感謝您的幫助。
我喜歡你的平均方法比我的更好,+1 –
謝謝......但我認爲還有另一種更快的解決方案:-)我在等待其他答案。 –
@chumkiu我試過你的答案,它完美的作品。謝謝 –