我有以下的JSON:PHP排序JSON從最高到最低
{
"ID":"4",
"name":"Gil",
"likes":0,
"Dec":"A Man"
},
{
"ID":"3",
"name":"Yoni",
"likes":3,
"Dec":"A child"
},
{
"ID":"6",
"name":"Roni",
"likes":1,
"Dec":"A woman"
}
而且我想基於從heighst到最低喜歡到rearange它這樣的結果將是:
{
"ID":"5",
"name":"Roni",
"likes":6,
"Dec":"A woman"
} ,
{
"ID":"3",
"name":"Yoni",
"likes":3,
"Dec":"A child"
},
{
"ID":"4",
"name":"Gil",
"likes":0,
"Dec":"A Man"
}
我如何在PHP中重新排列它?
隱蔽這個JSON來陣列json_decode(JSON,TRUE);使用一些數組排序函數對它進行排序然後重新創建json。 –
[按值排序多維數組]的可能重複(http://stackoverflow.com/questions/2699086/sort-multi-dimensional-array-by-value) –