我有一個數組,我需要排序,我會發佈一個例子,以便更好地理解。 這是我排序的數組:PHP - 一個數組的非標準排序
[0] => Array
(
[title] => This is some title
[catid] => 1
)
[1] => Array
(
[title] => This is some title
[catid] => 1
)
[2] => Array
(
[title] => This is some title
[catid] => 2
)
[3] => Array
(
[title] => This is some title
[catid] => 2
)
我需要重新梳理這樣的:
[0] => Array
(
[title] => This is some title
[catid] => 1
)
[1] => Array
(
[title] => This is some title
[catid] => 2
)
[2] => Array
(
[title] => This is some title
[catid] => 1
)
[3] => Array
(
[title] => This is some title
[catid] => 2
)
我將有更多的兩大類,我需要選擇每個類別的一個項目,所以如果我有3類,我在這種情況下CATID進行排序是這樣的:
CATID: 1,2,3,1,2,3
謝謝
可能它曾經是1,2,3,1,3? –
...或1,2,3,1,1,1? – 2014-01-23 00:57:20
更準確地說,如果沒有像1 2 1,2 2 3 3這樣的1,2,3的偶數陣容,會發生什麼 –