دنبال کننده ها

۱۳۹۶ شهریور ۱۱, شنبه

php - sorting multidimensional array by two values

[ad_1]



I have this array



Array
(
[arr1] => Array
(
[0] => Array
(
[m] => name1
[p] => 261.15
[f] => 0.30112588
)

[1] => Array
(
[m] => name2
[p] => 214.92
[f] => 0.35793662
)

[2] => Array
(
[m] => name3
[p] => 504.35
[f] => 0.35779595
)

[3] => Array
(
[m] => name3
[p] => 504.35
[f] => 0.31910875
)

[4] => Array
(
[m] => name3
[p] => 504.35
[f] => 0.38972548
)

[5] => Array
(
[m] => name4
[p] => 5500
[f] => 0.50674623
)

[6] => Array
(
[m] => name5
[p] => 600.5
[f] => 0.11483321
)
)
)


I want to sort this array so item with higest ['p'] is on top , but i also want if some items have same ['m'] and same ['p'] than an item with lowest ['f'] is on top of these with same ['m'] and ['p'].



I managed to sort this array by ['p'] using usort function , but i cant sort it by ['f'] only if they have same ['m'] and ['p'].




[ad_2]

لینک منبع