我有一個多維數組。現在我需要按照一個值的順序對這個數組進行排序。使用值排序多維數組
下面是這個數組的print_r的:
Array
(
[2] => Array
(
[NoticeType] => Invoice or Statement
[PhoneNumber] => 2222222222
[NoticeIdentifier] => Firm1
[NoticeDescription] => test
[AdditionalComments] => test1
[LineItemGHN] => Monthly Charges
[Amount] => 100
[StartDate] => 21/10/2014
[EndDate] =>
[TaxGroup] => GP-1 (GP-1. Service Tax (12) + Edu Cess (0.24) + Sec & High Edu Cess (0.12) for a total of 12.36%)
)
[3] => Array
(
[NoticeType] => Notice
[PhoneNumber] => 3333333333
[NoticeIdentifier] => Firm1
[NoticeDescription] => test2
[AdditionalComments] => test2
[LineItemGHN] => Half Yearly Subscription
[Amount] => 200
[StartDate] => 21/10/2014
[EndDate] =>
[TaxGroup] => GP-0 (No Taxes)
)
[4] => Array
(
[NoticeType] => Invoice or Statement
[PhoneNumber] => 2222222222
[NoticeIdentifier] => Firm1
[NoticeDescription] => test
[AdditionalComments] => test1
[LineItemGHN] => Discounts
[Amount] => 50
[StartDate] => 21/10/2014
[EndDate] =>
[TaxGroup] => GP-1 (GP-1. Service Tax (12) + Edu Cess (0.24) + Sec & High Edu Cess (0.12) for a total of 12.36%)
)
[5] => Array
(
[NoticeType] => Invoice or Statement
[PhoneNumber] => 2222222222
[NoticeIdentifier] => Firm2
[NoticeDescription] => test
[AdditionalComments] => test1
[LineItemGHN] => Monthly Charges
[Amount] => 2500
[StartDate] => 21/10/2014
[EndDate] =>
[TaxGroup] => GP-1 (GP-1. Service Tax (12) + Edu Cess (0.24) + Sec & High Edu Cess (0.12) for a total of 12.36%)
)
我需要排序這個數組根據PhoneNumber
.I'm從去年4個小時艱苦努力我的運氣。如何做那個排序?
給代碼,你試過 – 2014-11-06 09:08:41
http://stackoverflow.com/questions/2699086/sort-multi-dimensional-array-by-value檢查此鏈接。 – Piyush 2014-11-06 09:10:55
@suby 我在'$ var'中得到這個數組。所以這是我試過 'foreach($ var as $ key => $ val){ \t \t $ PhoneNumber = $ val ['PhoneNumber']; \t \t \t $ NoticeIdentifier = $ val ['NoticeIdentifier']; \t \t \t $ StartDate = $ val ['StartDate']; \t \t \t $ newAr [$ NoticeIdentifier] [$ StartDate] [$ PhoneNumber] [] = $ val; \t}' – Kanav 2014-11-06 10:16:15