1
我想按鍵組合數組。因此,所有以相同子密鑰開始的子數組將被組合成一個子數組。另外,我想保留匹配值的最小值。在PHP中組合子數組
目前,這是我所:
$statement = Array
(
[662_0] => Array
(
[0] => 06-01-2012
[1] => 436
[2] => MEDIA
[3] => 2006
[4] => Template Testing
[5] => KS
[6] => 662
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
[12] => 1290
[13] => 1290.00
[14] => 0.00
[15] => 0
[16] => 1290.00
)
[662_1] => Array
(
[0] => 06-01-2012
[1] => 436
[2] => MEDIA
[3] => 2006
[4] => Template Testing
[5] => KS
[6] => 662
[7] => 295.00
[8] => 0
[9] => 0
[10] => 0
[11] => 0
[12] => 995
[13] => 1290.00
[14] => 0.00
[15] => 0
[16] => 1290.00
)
[662_2] => Array
(
[0] => 06-01-2012
[1] => 436
[2] => MEDIA
[3] => 2006
[4] => Template Testing
[5] => KS
[6] => 662
[7] => 0
[8] => 0
[9] => 0
[10] => 0
[11] => 0
[12] => 1290
[13] => 1290.00
[14] => 0.00
[15] => 0
[16] => 1290.00
)
[663_0] => Array
(
blah blah blah...
)
);
這是我想擁有的一切:
$statement = Array
(
[662] => Array
(
[0] => 06-01-2012
[1] => 436
[2] => MEDIA
[3] => 2006
[4] => Template Testing
[5] => KS
[6] => 662
[7] => 295.00
[8] => 0
[9] => 0
[10] => 0
[11] => 0
[12] => 995
[13] => 1290.00
[14] => 0.00
[15] => 0
[16] => 1290.00
)
[663] => Array
(
blah blah blah...
)
);
快樂需要時提供更多信息!謝謝!!!
爲什麼標記爲[tag:mysql]?數據來自MySQL查詢嗎?也許最簡單的解決辦法是從那個方面改變它? – eggyal
你到目前爲止嘗試過什麼來排序和合並數組並返回結果? – Jrod
eggyal:是的,數據是從MySQL查詢填充的。我有/正在改變這方面的方法以及.http://stackoverflow.com/questions/10983362/combine-results-for-sql-query Jrod:我已經嘗試array_merge,array_multisort,並與implode組合但無法獲得理想的結果。我添加了任何有用的信息,但是有很多,這就是爲什麼我沒有把它全部放到一開始。謝謝! – Drewness