这是从 mysql 查询推送的输出数组
Array
(
[0] => Array
(
[CategoryID] => 7
[CategoryName] => Test it
[Parent] => 2
[Thumb] => 4
[sort] => 0
[MediaID] => 4
[MediaTitle] => asd
[MediaName] => 1349012691_4.jpg
[MediaType] => image
[MediaSize] => 369848
[UploadTime] => 1349012691
)
[1] => Array
(
[CategoryID] => 8
[CategoryName] => Test all
[Parent] => 4
[Thumb] => 5
[sort] => 0
[MediaID] => 5
[MediaTitle] => asaas
[MediaName] => 1349012728_9.jpg
[MediaType] => image
[MediaSize] => 416817
[UploadTime] => 1349012728
)
[2] => Array
(
[CategoryID] => 4
[CategoryName] => Test Image
[Parent] => 0
[Thumb] => 0
[sort] => 2
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[3] => Array
(
[CategoryID] => 2
[CategoryName] => Test Sub
[Parent] => 1
[Thumb] => 0
[sort] => 4
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[4] => Array
(
[CategoryID] => 3
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 6
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[5] => Array
(
[CategoryID] => 1
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 8
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[6] => Array
(
[CategoryID] => 5
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 10
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[7] => Array
(
[CategoryID] => 6
[CategoryName] => Test Remove
[Parent] => 0
[Thumb] => 0
[sort] => 12
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
)
我需要对这个数组进行排序,以便它首先显示父母类别,然后是子类别。
我需要类似的输出
Array
(
[2] => Array
(
[CategoryID] => 4
[CategoryName] => Test Image
[Parent] => 0
[Thumb] => 0
[sort] => 2
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
//sub category
[1] => Array
(
[CategoryID] => 8
[CategoryName] => Test all
[Parent] => 4
[Thumb] => 5
[sort] => 0
[MediaID] => 5
[MediaTitle] => asaas
[MediaName] => 1349012728_9.jpg
[MediaType] => image
[MediaSize] => 416817
[UploadTime] => 1349012728
)
[3] => Array
(
[CategoryID] => 2
[CategoryName] => Test Sub
[Parent] => 1
[Thumb] => 0
[sort] => 4
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
//sub category
[0] => Array
(
[CategoryID] => 7
[CategoryName] => Test it
[Parent] => 2
[Thumb] => 4
[sort] => 0
[MediaID] => 4
[MediaTitle] => asd
[MediaName] => 1349012691_4.jpg
[MediaType] => image
[MediaSize] => 369848
[UploadTime] => 1349012691
)
[4] => Array
(
[CategoryID] => 3
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 6
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[5] => Array
(
[CategoryID] => 1
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 8
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[6] => Array
(
[CategoryID] => 5
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 10
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
[7] => Array
(
[CategoryID] => 6
[CategoryName] => Test Remove
[Parent] => 0
[Thumb] => 0
[sort] => 12
[MediaID] =>
[MediaTitle] =>
[MediaName] =>
[MediaType] =>
[MediaSize] =>
[UploadTime] =>
)
)
我可以用 PHP 做到这一点吗?