-2
我對排序數組有問題。按子陣列數排序多維數組
我有這樣我的類別數組:
Array
(
[0] => Array
(
[title] => category
[url] => http//mycategoryurl
[subcategory] => Array
(
[0] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[1] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[2] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
)
)
[1] => Array
(
[title] => category
[url] => http//mycategoryurl
[subcategory] => Array
(
[0] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[1] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[2] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[3] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
)
)
[2] => Array
(
[title] => category
[url] => http//mycategoryurl
[subcategory] => Array
(
[0] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[1] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
)
)
)
我想排序這個數組由count(subcategory)
像這樣的:
Array
(
[0] => Array
(
[title] => category
[url] => http//mycategoryurl
[subcategory] => Array
(
[0] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[1] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[2] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[3] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
)
)
[1] => Array
(
[title] => category
[url] => http//mycategoryurl
[subcategory] => Array
(
[0] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[1] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[2] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
)
)
[2] => Array
(
[title] => category
[url] => http//mycategoryurl
[subcategory] => Array
(
[0] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
[1] => Array
(
[title] => category - first
[url] => http//mycategoryurl
)
)
)
)
請幫我在我的例子排序這個數組等。
這是工作,但我想排序是遞減。現在它是acs。謝謝 –
交換'-1'和'1' –
我改變了「<" to ">」。現在是好的。非常感謝你,我的朋友 –