【发布时间】:2016-07-06 17:50:45
【问题描述】:
给定一个对象数组,其中数组中的每个对象如下所示:
"success": true,
"data": [
{
"doctor_id": 4, -- Use this id for getting in method get inquiry doctor offers.
"clinic": "John",
"distance": "10 mile"
"city": "Los Angeles",
"price": "123",
"photo": false,
"rating": {
"stars": null,
"reviews": null
},
"add_info"=> "Some information",
"time_after_create": 942 -- in seconds.
}
]
在 php 中是否有任何方法可以让我按 $data->price 从低到高和从高到低排序,然后还按 $data->rating->stars其中 stars 是 0 到 5 之间的数字排序?
我看了一下答案here,其中谈到了array_multisort()。
但我不确定它是否能达到我想要的效果。
欢迎提出任何想法或见解。
【问题讨论】:
-
stackoverflow.com/questions/1597736/…?我最喜欢的是第二个答案